将java类导入JSP
这就是问题所在。
我使用 NetBeans 7
、Tomcat 7
和 hsqldb
开发了一个 Web 应用程序;在我的桌面上一切正常。
当我将 java 文件(.class、.jsp 和 .jar 包)上传到我的站点并尝试加载一个 jsp 页面时,该页面导入包中包含的类(包 中的类
),我收到以下错误:FunzioniSessione
it.swlab.util
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. it.swlab.util.FunzioniSessione resolves to a package
An error occurred at line: 7 in the jsp file: /index.jsp
FunzioniSessione cannot be resolved to a type
4: <%
5: synchronized(this)
6: {
7: FunzioniSessione funzioniSessione = new FunzioniSessione();
8: String percorso = config.getServletContext().getRealPath("/");
9: funzioniSessione.inizializza(session,request,response,percorso,"infocar");
10: boolean connesso = session.getAttribute("utenteConnesso") != null;
An error occurred at line: 7 in the jsp file: /index.jsp
FunzioniSessione cannot be resolved to a type
4: <%
5: synchronized(this)
6: {
7: FunzioniSessione funzioniSessione = new FunzioniSessione();
8: String percorso = config.getServletContext().getRealPath("/");
9: funzioniSessione.inizializza(session,request,response,percorso,"infocar");
10: boolean connesso = session.getAttribute("utenteConnesso") != null;
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:309)
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)
note The full stack trace of the root cause is available in the Apache Tomcat/5.5.33 logs.
为了防止出现一些明显的答案,我添加了一些更多信息:
- 包含类 FunzioniSessione 的包(名为
funzioniComuni.jar
)位于WEB-INF\lib
文件夹 - 我无法按照堆栈跟踪中的注释查看日志,因为我无权访问提供商的 Tomcat 服务器的日志文件夹。 3 导入指令为
<%@page import="it.swlab.util.FunzioniSessione"%>
我也尝试过使用“;”最后 (<%@page import="it.swlab.util.FunzioniSessione;"%>
) 但没有成功。
我等待一些建议。
谢谢
That's the problem.
I developed a web app with NetBeans 7
, Tomcat 7
and hsqldb
; on my desktop all is Ok.
When I upload my java files (.class, .jsp and .jar packages) to my site and try to load a jsp page which imports a class contained in a package (class FunzioniSessione
in package it.swlab.util
), I get the following error:
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. it.swlab.util.FunzioniSessione resolves to a package
An error occurred at line: 7 in the jsp file: /index.jsp
FunzioniSessione cannot be resolved to a type
4: <%
5: synchronized(this)
6: {
7: FunzioniSessione funzioniSessione = new FunzioniSessione();
8: String percorso = config.getServletContext().getRealPath("/");
9: funzioniSessione.inizializza(session,request,response,percorso,"infocar");
10: boolean connesso = session.getAttribute("utenteConnesso") != null;
An error occurred at line: 7 in the jsp file: /index.jsp
FunzioniSessione cannot be resolved to a type
4: <%
5: synchronized(this)
6: {
7: FunzioniSessione funzioniSessione = new FunzioniSessione();
8: String percorso = config.getServletContext().getRealPath("/");
9: funzioniSessione.inizializza(session,request,response,percorso,"infocar");
10: boolean connesso = session.getAttribute("utenteConnesso") != null;
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:309)
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)
note The full stack trace of the root cause is available in the Apache Tomcat/5.5.33 logs.
To prevent some obvious answers, I add some more information:
- The package containing the class FunzioniSessione (named
funzioniComuni.jar
) is in theWEB-INF\lib
folder - I can't look at the logs as the note in the stacktrace suggests, because I have no access to the logs folder of my provider's Tomcat server.
3 The directive for the import is<%@page import="it.swlab.util.FunzioniSessione"%>
I tried also with a ";" at the end (<%@page import="it.swlab.util.FunzioniSessione;"%>
) but with no success.
I wait for some suggestions.
Thank you
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
FunzioniSessione 在您的类路径中吗?一般来说,我们将类保存在已经在 onclasspth 中的 web-inf\classes 中。您能否确保部署目录具有这种结构,并且您的类位于预期的包中?
Is the FunzioniSessione on you classpath ? Generally we keep the classes in web-inf\classes which is already onclasspth. Can you ensure the deployment directory has this structure with you class in expected package ?