Servlet实现文件上传时候出现了错误,紧急求救!! 50
ApacheTomcat/5.0.28-ErrorreportHTTPStatus500-typeExceptionreportmessagedescriptionThe...
Apache Tomcat/5.0.28 - Error reportHTTP Status 500 -
type Exception report
message
description The server encountered an internal error () that prevented it from
fulfilling this request.
exception
javax.servlet.ServletException: Error instantiating servlet class servlets.FileUpload
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:118)
org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:160)
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:799)
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:705)
org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:577)
org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:683)
java.lang.Thread.run(Thread.java:619)
root cause
java.lang.Error: Unresolved compilation problems:
The import org.apache.commons.fileupload.FileItem cannot be resolved
The import org.apache.commons.fileupload.disk.DiskFileItemFactory cannot be resolved
The import org.apache.commons.fileupload.servlet.ServletFileUpload cannot be resolved
ServletFileUpload cannot be resolved
org.apache.commons.fileupload.FileItemFactory cannot be resolved to a type
DiskFileItemFactory cannot be resolved to a type
ServletFileUpload cannot be resolved to a type
ServletFileUpload cannot be resolved to a type
FileItem cannot be resolved to a type
FileItem cannot be resolved to a type
servlets.FileUpload.<init>(FileUpload.java:13)
sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
java.lang.reflect.Constructor.newInstance(Constructor.java:513)
java.lang.Class.newInstance0(Class.java:355)
java.lang.Class.newInstance(Class.java:308)
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:118)
org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:160)
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:799)
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:705)
org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:577)
org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:683)
java.lang.Thread.run(Thread.java:619)
note The full stack trace of the root cause is available in the Apache
Tomcat/5.0.28 logs.
Apache Tomcat/5.0.28
--------------------------------
用upload.jsp提交需要上传的文件,然后在Filepload.java中实现上传时出现了这样一个问题。
谢谢。
enctype="multipart/form-data" 我是加了的。
不是这个问题。而且那两个实现上传功能的jar文件我也拷贝到WEB-INF\lib下面的。
但是就是不能解决,花了我好多时间了。请高手帮帮忙。 展开
type Exception report
message
description The server encountered an internal error () that prevented it from
fulfilling this request.
exception
javax.servlet.ServletException: Error instantiating servlet class servlets.FileUpload
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:118)
org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:160)
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:799)
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:705)
org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:577)
org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:683)
java.lang.Thread.run(Thread.java:619)
root cause
java.lang.Error: Unresolved compilation problems:
The import org.apache.commons.fileupload.FileItem cannot be resolved
The import org.apache.commons.fileupload.disk.DiskFileItemFactory cannot be resolved
The import org.apache.commons.fileupload.servlet.ServletFileUpload cannot be resolved
ServletFileUpload cannot be resolved
org.apache.commons.fileupload.FileItemFactory cannot be resolved to a type
DiskFileItemFactory cannot be resolved to a type
ServletFileUpload cannot be resolved to a type
ServletFileUpload cannot be resolved to a type
FileItem cannot be resolved to a type
FileItem cannot be resolved to a type
servlets.FileUpload.<init>(FileUpload.java:13)
sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
java.lang.reflect.Constructor.newInstance(Constructor.java:513)
java.lang.Class.newInstance0(Class.java:355)
java.lang.Class.newInstance(Class.java:308)
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:118)
org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:160)
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:799)
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:705)
org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:577)
org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:683)
java.lang.Thread.run(Thread.java:619)
note The full stack trace of the root cause is available in the Apache
Tomcat/5.0.28 logs.
Apache Tomcat/5.0.28
--------------------------------
用upload.jsp提交需要上传的文件,然后在Filepload.java中实现上传时出现了这样一个问题。
谢谢。
enctype="multipart/form-data" 我是加了的。
不是这个问题。而且那两个实现上传功能的jar文件我也拷贝到WEB-INF\lib下面的。
但是就是不能解决,花了我好多时间了。请高手帮帮忙。 展开
2个回答
展开全部
你有没设置表单的类型?
没有的话加上 enctype="multipart/form-data"
没有的话加上 enctype="multipart/form-data"
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
DataBaseConnection db=new DataBaseConnection();
db.setAuthor(author);
java.io.File f=new java.io.File("../webapps/OpenSource/"+author);
String path="../webapps/OpenSource/";
if(f.exists()==false)
{
f.mkdir();
}
try{
SmartUpload su = new SmartUpload();
su.initialize(servletconfig, request, response);
su.setMaxFileSize(900000000);
su.setTotalMaxFileSize(900000000);
su.setAllowedFilesList("chm,doc,txt,rar,java,zip,jar,sql,pdf,ppt,xls");
su.setDeniedFilesList("exe,bat,jsp,htm,html,,");
su.upload();
for (int i=0;i<su.getFiles().getCount();i++)
{
com.jspsmart.upload.File file = su.getFiles().getFile(i);
if (file.isMissing()) continue;
file.saveAs(path+author+"/" + file.getFileName());
session.setAttribute("filename",file.getFileName());
}
session.setAttribute("message","上传成功!");
session.setAttribute("state","true");
response.sendRedirect("../OpenSource/index.jsp");
}
catch(Exception e){
e.printStackTrace();
session.setAttribute("message","上传失败!");
response.sendRedirect("../OpenSource/index.jsp");
}
db.setAuthor(author);
java.io.File f=new java.io.File("../webapps/OpenSource/"+author);
String path="../webapps/OpenSource/";
if(f.exists()==false)
{
f.mkdir();
}
try{
SmartUpload su = new SmartUpload();
su.initialize(servletconfig, request, response);
su.setMaxFileSize(900000000);
su.setTotalMaxFileSize(900000000);
su.setAllowedFilesList("chm,doc,txt,rar,java,zip,jar,sql,pdf,ppt,xls");
su.setDeniedFilesList("exe,bat,jsp,htm,html,,");
su.upload();
for (int i=0;i<su.getFiles().getCount();i++)
{
com.jspsmart.upload.File file = su.getFiles().getFile(i);
if (file.isMissing()) continue;
file.saveAs(path+author+"/" + file.getFileName());
session.setAttribute("filename",file.getFileName());
}
session.setAttribute("message","上传成功!");
session.setAttribute("state","true");
response.sendRedirect("../OpenSource/index.jsp");
}
catch(Exception e){
e.printStackTrace();
session.setAttribute("message","上传失败!");
response.sendRedirect("../OpenSource/index.jsp");
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询