日期:2014-05-17  浏览次数:20846 次

SmartUpload 上传报错
SmartUpload smartupload = new SmartUpload();
smartupload.initialize(this.getServletConfig(),request,response);
String imagename = null;
String iname = null;
//准备上传
try {
说这行报错//smartupload.upload() ;
IPTimeStamp ip = new IPTimeStamp();
iname = ip.getIPTimeStampRand()+"."+smartupload.getFiles().getFile(0).getFileExt();
imagename = this.getServletContext().getRealPath("/")+"admin/"+iname;
smartupload.getFiles().getFile(0).saveAs(imagename) ;
} catch (SmartUploadException e) {
e.printStackTrace();
}













严重: Servlet.service() for servlet GoodsServlet threw exception
java.lang.NegativeArraySizeException
at org.lxh.smart.SmartUpload.upload(SmartUpload.java:133)
at com.wxw.servlet.GoodsServlet.add(GoodsServlet.java:150)
at com.wxw.servlet.GoodsServlet.doPost(GoodsServlet.java:46)
at com.wxw.servlet.GoodsServlet.doGet(GoodsServlet.java:24)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:690)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at com.wxw.servlet.EncodingFilter.doFilter(EncodingFilter.java:15)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:228)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:104)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:216)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:634)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:445)
at java.lang.Thread.run(Thread.java:619)




------解决方案--------------------
是初始化设置没有对吧