[英]javax.servlet.ServletException: java.lang.NoClassDefFoundError: org/apache/commons/io/output/DeferredFileOutputStream
I am trying to upload a file using JSP and I got the error as org.apache.jasper.JasperException:
An exception occurred processing JSP page /upload.jsp
at line 31 我正在尝试使用JSP上传文件,并且出现org.apache.jasper.JasperException:
错误org.apache.jasper.JasperException:
第31行处理JSP页面/upload.jsp
时发生异常
28: upload.setSizeMax( maxFileSize );
29: try{
30: // Parse the request to get file items.
31: List fileItems = upload.parseRequest(request);
32:
33: // Process the uploaded file items
34: Iterator i = fileItems.iterator();
exception that I got is: 我得到的例外是:
javax.servlet.ServletException: java.lang.NoClassDefFoundError: org/apache/commons/io/output/DeferredFileOutputStream
org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:912)
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:841)
org.apache.jsp.upload_jsp._jspService(upload_jsp.java:154)
java.lang.NoClassDefFoundError: org/apache/commons/io/output/DeferredFileOutputStream java.lang.NoClassDefFoundError:org / apache / commons / io / output / DeferredFileOutputStream
This means that the mentioned class is missing in webapp's runtime classpath. 这意味着在webapp的运行时类路径中缺少提到的类。 As the package name hints, it's part of Apache Commons IO . 正如软件包名称所暗示的那样,它是Apache Commons IO的一部分。 You need to download the zip file containing the binary JARs, extract it and then drop commons-io.jar
in your webapp's /WEB-INF/lib
folder, along with the commons-fileupload.jar
which you should already have there. 您需要下载包含二进制JAR的zip文件, 将其解压缩,然后将commons-io.jar
以及应该已经存在的commons-fileupload.jar
放到/WEB-INF/lib
应用程序的/WEB-INF/lib
文件夹中。
Do not put it in Tomcat's /lib
while having the commons-fileupload.jar
in webapp's /WEB-INF/lib
. 不要把它放在Tomcat的/lib
,同时具有commons-fileupload.jar
在web应用程序的/WEB-INF/lib
。 Do not fiddle around in project's Build Path setting. 不要在项目的构建路径设置反复折腾。 Just drop the two JARs in webapp's /WEB-INF/lib
and you should be all set. 只需将两个JAR放在webapp的/WEB-INF/lib
,就可以完成所有工作。
Unrelated to the concrete problem, Java code doesn't belong in JSP files. 与具体问题无关 ,Java代码不属于JSP文件。 It belongs in Java classes. 它属于Java类。 It's time to learn how to create and use servlets before it's too late. 现在该学习为时已晚的如何创建和使用servlet的时候了。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.