我写了一个FileUpload.java文件如下import java.io.*;
import java.util.*;
import javax.servlet.*;
import javax.servlet.http.*;
import org.apache.commons.fileupload.*;
public class FileUpload extends HttpServlet
{
private String uploadPath="C:\\upload\\";
private String tempPath="c:\\upload\\tmp\\";
public void doPost(HttpServletRequest request,HttpServletResponse response) throws IOException,ServletException
{
try
{
DiskFileUpload fu=new DiskFileUpload();
fu.setSizeMax(4194304);
fu.setSizeThreshold(4096);
fu.setRepositoryPath(tempPath);
List fileItems=fu.parseRequest(request);
Iterator i=fileItems.iterator();
while(i.hasNext())
{
FileItem fi=(FileItem)i.next();
String fileName=fi.getName();
if(fileName!=null)
{
fi.write(new File(uploadPath+"a.txt"));
}
}
}
catch(Exception e)
{
System.out.println(e.toString());
}
}
public void init(ServletConfig config)throws ServletException
{
uploadPath="C:\\upload\\";
tempPath="c:\\upload\\tmp\\";
if(!new File(uploadPath).isDirectory())
{
new File(uploadPath).mkdirs();
}
if(!new File(tempPath).isDirectory())
{
new File(tempPath).mkdirs();
}
super.init(config);
}
}
html文件如下:
<html>
<head><title>FileUpLoad</title></head>
<body>
<form action="http://localhost:8000/a/a" method="post" enctype="multipart/form-data" name="form1">
  <input type="file" name="file">
  <input type="submit" name="Submit" value="upload">
</form>
</body>
</html>
用j2ee的部署工具deploytool 部署FileUpload.class 为servlet 但冲击html中的upload出现了javax.servlet.ServletException: Error instantiating servlet class FileUpload与java.lang.NoClassDefFoundError: org/apache/commons/fileupload/FileUploadBase这两个错误....
请哪位侠给我看看哪里出了问题啊..???