我这个upload哪里错了?
怎摸我的/message(路径绝对正确)目录存在,但一运行就抛这个异常的?
Exception:
java.lang.ArrayIndexOutOfBoundsException: 0
newsf.UploadTest.doPost(UploadTest.java:31)
javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
note The full stack trace of the root cause is available in the Apache Tomcat/5.0.27
我的upload的那个servlet是这样写的:
package newsf;
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
import java.util.*;
import com.upload.beans.Upload;
public class UploadTest
extends HttpServlet {
private static final String CONTENT_TYPE = "text/html; charset=GB18030 ";
private Random rnd=new Random();
//Initialize global variables
public void init() throws
ServletException {
}
//Process the HTTP Post request
public void doPost(HttpServletRequest request, HttpServletResponse response) throws
ServletException,
IOException {
String path=getServletContext().getRealPath( "message ");
String name=null;
Upload up=new Upload();
up.init(request);
//up.setMaxFileSize(10 * 1024 * 1024);
up.setSaveDir(path);
up.setTagFileName(getRandName());
up.uploadFile();
name=up.getFileName()[0];
up.getParameter( "title ");
response.sendRedirect( "message/ "+name);
}
private String getRandName(){
return String.valueOf(rnd.nextLong());
}
//Clean up resources
public void destroy() {
}
}
------解决方案--------------------common-io.jar导入了吗。。。。。。。。
------解决方案--------------------name=up.getFileName()[0];
------解决方案--------------------ArrayIndexOutOfBoundsException 明显的是
数组越界了