我正在努力解决一个奇怪的问题。我构建了一个jsp Web应用程序并在本地tomcat(版本6.0.36)上成功测试它。
我将应用程序部署在由cpanel 11管理的Web主机上 - 运行tomcat 5.5.36。当我打电话给一个页面时,我会收到这样的错误:
org.apache.jasper.JasperException: Unable to compile class for JSP:
An error occurred at line: 6 in the generated java file
Only a type can be imported. com.raya.web.language.LanguageTool resolves to a package
An error occurred at line: 4 in the jsp file: /index.jsp
LanguageTool cannot be resolved to a type
1: <%@ page import="com.raya.web.language.LanguageTool" %>
2: <%@ page contentType="text/html;charset=UTF-8" language="java" %>
3: <%
4: LanguageTool languageTool = new LanguageTool("fa");
5: %>
6: <!DOCTYPE HTML>
7: <html>
An error occurred at line: 4 in the jsp file: /index.jsp
LanguageTool cannot be resolved to a type
1: <%@ page import="com.raya.web.language.LanguageTool" %>
2: <%@ page contentType="text/html;charset=UTF-8" language="java" %>
3: <%
4: LanguageTool languageTool = new LanguageTool("fa");
5: %>
6: <!DOCTYPE HTML>
7: <html>
Stacktrace:
org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:93)
org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:330)
org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:451)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:328)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:307)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:295)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:565)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:311)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:308)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:259)
javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
我找不到解决方案。
感谢任何帮助。
答案 0 :(得分:1)
我认为问题是因为依赖关系和库。所以我将文件jsp-api.jar添加到'/ WEB-INF / lib'并重新部署了web应用程序,它运行良好。
答案 1 :(得分:0)
尝试像
一样实例化LanguageTool<%! LanguageTool languageTool = new LanguageTool("fa");%>
注意&lt;%!