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下面的。
但是就是不能解决,花了我好多时间了。请高手帮帮忙。
展开
 我来答
賊兔一一
2009-03-17 · 超过26用户采纳过TA的回答
知道答主
回答量:60
采纳率:0%
帮助的人:0
展开全部
你有没设置表单的类型?

没有的话加上 enctype="multipart/form-data"
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
lichaoever
2009-03-18 · 超过23用户采纳过TA的回答
知道答主
回答量:72
采纳率:0%
帮助的人:0
展开全部
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");
}
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
收起 1条折叠回答
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式