我用smartupload组件进行文件上传时报出下面异常,大家帮忙看看怎么回事!!
java.lang.IllegalArgumentException: Files' name is invalid or does not exist (1205).
at com.jspsmart.upload.Files.getFile(Files.java:73)
at contraller.UploadServlet.doPost(UploadServlet.java:49)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)
at org.apache.coyote.http11.Http11AprProcessor.process(Http11AprProcessor.java:859)
at org.apache.coyote.http11.Http11AprProtocol$Http11ConnectionHandler.process(Http11AprProtocol.java:574)
at org.apache.tomcat.util.net.AprEndpoint$Worker.run(AprEndpoint.java:1527)
at java.lang.Thread.run(Unknown Source)

解决方案 »

  1.   

    servlet代码:
           public class UploadServlet extends HttpServlet {
    private static final long serialVersionUID = 1L; public void doGet(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException {
    doPost(request, response);
    } public void doPost(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException {
    request.setCharacterEncoding("gbk");
    SmartUpload su = new SmartUpload();
    String fileName = "";
    String sfilelength = "";
    String filetype = "";
    String suploadtime = "";
    UploadEntity uploadentity = new UploadEntity();
    try {
    su.initialize(this.getServletConfig(), request, response);
    su.upload();
    String title = su.getRequest().getParameter("title");
    String re = su.getRequest().getParameter("re");
    su.save("F://upload"); File file = su.getFiles().getFile(0);
    fileName = file.getFieldName();
    int ifilelength = file.getSize();
    sfilelength = Integer.toString(ifilelength);
    filetype = file.getFileExt();
    Date dt = new Date();
    suploadtime = String.valueOf(1900 + dt.getYear() + "-"
    + String.valueOf(1 + dt.getMonth()) + "-"
    + String.valueOf(dt.getDate())); uploadentity.setFileName(fileName);
    uploadentity.setFileLength(sfilelength);
    uploadentity.setFileType(filetype);
    uploadentity.setFileUploadTime(suploadtime);
    uploadentity.setFileTitle(title);
    uploadentity.setFileDescribe(re);
    UploadManage um = new UploadManage();
    um.upload(uploadentity);
    request.getRequestDispatcher("/result.jsp").forward(request,
    response);
    } catch (Exception e) {
    e.printStackTrace();
    }
    }
    public void init(ServletConfig config) throws ServletException {
    }
    }
      

  2.   

    jsp代码:
         <body> 
    <p> </p> 
    <p align="center">上传信息输入</p> 
    <FORM name="myform" METHOD="POST" ACTION="/smartupload/uploadServlet" 
    ENCTYPE="multipart/form-data"> 
    <table width="75%" border="1" align="center"> 
    <tr> 
    <td><div align="left">
    <input type="FILE" name="FILE1" size="30"> 
    </div></td> 
    </tr> 
    <tr> 
    <td><div align="left"> 
    </div></td> 
    </tr> 
    <tr> 
    <td>标    题:<input type=text name=title size=37 ></td>
    </tr>
    <tr>
    <td>信息描述:<textarea name=re cols=50 rows=8></textarea></td>
    </tr>
    <tr> 
    <td colspan="2"><div align="center"> 
    <input type="submit" value="提交" >
    </div></td>
    </tr>
    </table> 
    </FORM> 
    </body>