<%@ page import =“org.apache.commons.fileupload。*”%> //一些代码...... DiskFileUpload fu = new DiskFileUpload();
我正在尝试使用apache commons函数DiskFileUpload,但它有一个异常,因为无法找到fileupload.jar。我在这个论坛中查看与此类问题相关的其他回复,人们建议在WEB-INF / lib中添加该文件,我尝试但是它不适用于我。
也许我把它放在错误的位置? 我的jsp路径是:apache-tomcat-6.0.29 / webapps / ROOT / ClockAdmin / upload.jsp WEB-INF是:apache-tomcat-6.0.29 / webapps / WEB-INF / commons-fileupload-1.2.2.jar LIB / 我看看其他帖子,但它仍然无效: Apache commons -> File Upload -> parseRequest() error
我得到以下例外:
org.apache.jasper.JasperException: Unable to compile class for JSP:
An error occurred at line: 36 in the jsp file: /ClockAdmin/uploader2.jsp
DiskFileUpload cannot be resolved to a type
33: System.out.println( "CONTENT-LENGHT" + request.getContentLength());
34: System.out.println("session id = " + session.getId());
35:
36: DiskFileUpload fu = new DiskFileUpload();
37: // maximum size before a FileUploadException will be thrown
38: fu.setSizeMax(5000000);
39: // maximum size that will be stored in memory
An error occurred at line: 36 in the jsp file: /ClockAdmin/uploader2.jsp
DiskFileUpload cannot be resolved to a type
33: System.out.println( "CONTENT-LENGHT" + request.getContentLength());
34: System.out.println("session id = " + session.getId());
35:
36: DiskFileUpload fu = new DiskFileUpload();
37: // maximum size before a FileUploadException will be thrown
38: fu.setSizeMax(5000000);
39: // maximum size that will be stored in memory
An error occurred at line: 48 in the jsp file: /ClockAdmin/uploader2.jsp
FileItem cannot be resolved to a type
45: Iterator item = fileItems.iterator();
46: while(item.hasNext())
47: {
48: FileItem fi = (FileItem) item.next();
49: if(fi.isFormField())
50: {
51: continue;
An error occurred at line: 48 in the jsp file: /ClockAdmin/uploader2.jsp
FileItem cannot be resolved to a type
45: Iterator item = fileItems.iterator();
46: while(item.hasNext())
47: {
48: FileItem fi = (FileItem) item.next();
49: if(fi.isFormField())
50: {
51: continue;
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:349)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:327)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:314)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:592)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:317)
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)
答案 0 :(得分:0)
您需要在/WEB-INF/lib
文件夹中删除JAR,而不是/WEB-INF
。
答案 1 :(得分:0)
我不得不通过弹跳Tomcat服务器来手动部署WAR文件。这解压了WAR,当服务器重新启动时,它没有抛出任何异常。我只能想象我在Tomcat设置中的配置错误,以允许清单正确关闭并重新打开。