关于jsp+tomcat7.0的问题
本帖最后由 fstao 于 2012-12-28 17:53:13 编辑
我已经配置好了tomcat7.0,在ie里录入:http://localhost:8080/,出来是正常的界面,说明配置没有问题了。由于我把tomcat7.0是用安装程序,安装在c盘的,如“C:\Program Files\Apache Software Foundation\Tomcat 7.0”,我在webapps里增加了文件夹:myapp,在mayapp文件夹下增加WEB-INF的文件夹,在WEB-INF下增加一个文件“web.xml”,代码如下:
<?xml version="1.0" encoding="gb2312"?>
<web-app>
<display-name>My Web Application</display-name>
<description>
A application for test
</description>
</web-app>
我又在myapp的目录下增加一个"index.jsp",代码如下:
<html>
<body>
<center>Now time is: <%=new java.util.date()%></center>
</body>
</html>
我重启了tompcat7.0,我在ie地址录入:http://localhost:8080/myapp/index.jsp,回车出现错误:
HTTP Status 500 - Unable to compile class for JSP:
type Exception report
messageUnable to compile class for JSP:
descriptionThe server encountered an internal error that prevented it from fulfilling this request.
exception
org.apache.jasper.JasperException: Unable to compile class for JSP:
An error occurred at line: 3 in the jsp file: /index.jsp
java.util.date cannot be resolved to a type
1: <html>
2: <body>
3: <center>Now time is: <%=new java.util.date()%></center>
4: </body>
5: </html>
Stacktrace:
org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:102)
org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:331)
org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:468)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:378)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:353)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:340)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:646)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:357)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
请问是什么问题?如何解决?
------解决方案--------------------不能编译啊,第三行那个new java.util.date()错了,改成new java.util.Date()就ok了