我有一个Java EE项目,其中包含三个文件delete.jsp
,index.jsp
和BooksWorker.java
。
即使我将index.jsp
放在WEB-IN / classes中,我也无法运行BooksWorker.class
。
我得到的错误:
type Exception report
message Unable to compile class for JSP:
description The 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: 24 in the jsp file: /index.jsp
BooksWorker cannot be resolved
21: String remark = request.getParameter("remark");
22: if (author != null && title != null
23: && year != null && remark!= null) {
24: BooksWorker.Insert(author, title, year, remark);
25: }
26: %>
27:
Stacktrace:
org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:92)
org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:330)
org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:439)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:356)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:334)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:321)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:592)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:328)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
note The full stack trace of the root cause is available in the Apache Tomcat/6.0.36 logs.
答案 0 :(得分:1)
尝试将BooksWorker
课程从unnamed package移至named package。 JSP编译器无法从[未命名的包]中访问类。
答案 1 :(得分:0)
最有可能的错误是由于没有在jsp中导入BooksWorker。
<%@page import="<package name>.BooksWorker"%>