我是 JSP 新手,以下是我的 jsp 文件
<HTML>
<BODY>
Hello! The time is now <%= new java.util.Date() %>
<%= System.getProperties().getProperty(java.version) %>
</BODY>
</HTML>
上面的jsp文件在APACHE SERVER上运行时出现如下错误
Unable to compile class for JSP:
An error occurred at line: 4 in the jsp file: /index.jsp
java.version cannot be resolved to a type
1: <HTML>
2: <BODY>
3: Hello! The time is now <%= new java.util.Date() %>
4: <%= System.getProperties().getProperty(java.version) %>
5: </BODY>
6: </HTML>
错误消息很少见,每 10 次刷新一次我都会收到错误消息。另外 9 次我得到所有系统属性的输出,即使我只需要系统的 java.version 属性也是如此。
最佳答案
<%= System.getProperties().getProperty(java.version) %>
替换为
<%= System.getProperties().getProperty("java.version") %>
getProperty()
方法需要输入的是String
类型,需要用双引号将String
传递过来。
关于java - Jsp 文件有时抛出内部服务器 500 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22195778/