无法为JSP加载类 [英] Unable to load class for JSP

查看:205
本文介绍了无法为JSP加载类的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

异常堆栈跟踪

org.apache.jasper.JasperException: Unable to load class for JSP
 org.apache.jasper.JspCompilationContext.load(JspCompilationContext.java:599)
 org.apache.jasper.servlet.JspServletWrapper.getServlet(JspServletWrapper.java:143)
 org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:321)
 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)

java.lang.ClassNotFoundException: org.apache.jsp.redirect_jsp
 java.net.URLClassLoader$1.run(Unknown Source)
 java.security.AccessController.doPrivileged(Native Method)
 java.net.URLClassLoader.findClass(Unknown Source)
 org.apache.jasper.servlet.JasperLoader.loadClass(JasperLoader.java:131)
 org.apache.jasper.servlet.JasperLoader.loadClass(JasperLoader.java:63)
 org.apache.jasper.JspCompilationContext.load(JspCompilationContext.java:597)
 org.apache.jasper.servlet.JspServletWrapper.getServlet(JspServletWrapper.java:143)
 org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:321)
 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)

我的redirect.jsp文件内容

My redirect.jsp file contents

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<% response.sendRedirect("user/list.htm"); %>


推荐答案

在servletcontainer的封面下,JSP被编译为Java类在执行之前。

Under the covers of the servletcontainer, JSP's are compiled to Java classes before they get executed.

异常

java.lang.ClassNotFoundException: org.apache.jsp.redirect_jsp

表示重定向.consp webcontent文件夹根目录中的文件无法编译,这反过来通常意味着它包含 scriptlet中的一些原始Java代码 <% %> ,其中包含语法错误。您需要修复这些语法错误,以便servletcontainer可以编译这些JSP文件。然而,一般的共识是 scriptlets 糟糕的做法。您应该考虑Java代码是否更好地属于一个完整的Java类,由 Servlet 过滤器。

means that the redirect.jsp file in the root of your webcontent folder failed to compile which in turn often means that it contains some raw Java code in scriptlets <% %> which contains syntax errors. You need to fix those syntax errors so that the servletcontainer can compile those JSP files. The general concensus is however that scriptlets are a poor practice. You should consider if that Java code doesn't better belong in a fullworthy Java class, controlled by a Servlet or a Filter.

另一个可能的原因是servletcontainer的工作缓存搞砸了。使用糟糕的IDE插件进行开发时可能会发生这种情况。您想清理工作缓存。在例如Eclipse中,您可以通过右键单击服务器并选择 Clean 来实现。否则,必须通过删除相关servletcontainer的工作缓存中的所有内容来手动完成。在例如Tomcat的情况下,那就是 / work 文件夹中的所有内容。

Another possible cause is that the work cache of the servletcontainer is messed up. This can happen when developing with a poor IDE plugin. You'd like to clean the work cache. In for example Eclipse, you can do that by rightclick the server and choosing Clean. Otherwise it has to be done manually by deleting everything in work cache of the servletcontainer in question. In case of for example Tomcat, that's then everything in side its /work folder.

这篇关于无法为JSP加载类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆