org.apache.commons.fileupload.FileUploadException: Processing of multipart/form-data request failed.
谁有成功的解决方案吗?

解决方案 »

  1.   

    上网找一个 jsp文件上传的列子看看
      

  2.   


    Upload.html:   
        
      <html>   
      <head>   
      <title>文件上传演示</title>   
      </head>   
      <body   bgcolor="#3399CC"   text="#000000"   leftmargin="0"   topmargin="40"   marginwidth="0"   marginheight="0">   
      <center>   
      <h1>文件上传演示</h1>   
      <form   name="uploadform"   method="POST"   action="save.jsp"   ENCTYPE="multipart/form-data">   
        <table   border="1"   width="450"   cellpadding="4"   cellspacing="2"   bordercolor="#9BD7FF">   
        <tr><td   width="100%"   colspan="2">   
        文件1:<input   name="file1"   size="40"   type="file">   
        </td></tr>   
        <tr><td   width="100%"   colspan="2">   
        文件2:<input   name="file2"   size="40"   type="file">   
        </td></tr>   
        <tr><td   width="100%"   colspan="2">   
        文件3:<input   name="file3"   size="40"   type="file">   
        </td></tr>   
        </table>   
        <br/><br/>   
        <table>   
        <tr><td   align="center"><input   name="upload"   type="submit"   value="开始上传"/></td></tr>   
        </table>   
      </form>   
      </center>   
      </body>   
      </html>   
        
      save.jsp:   
        
      <%@   page   language="java"contentType="text/html;charset=GBK"%>   
      <%@   page   import="java.util.*"%>   
      <%@   page   import="java.io.*"%>   
      <%@   page   import="org.apache.commons.fileupload.*"%>   
        
        
      <jsp:useBean   id="FileUpload"   class="org.apache.commons.fileupload.FileUpload"     >   </jsp:useBean>   
        
      <html>   
      <head>   
      <title>保存上传文件</title>   
      </head>   
      <%   
      System.out.println("...save.jsp....");   
      String   msg   =   "";   
      org.apache.commons.fileupload.DiskFileUpload   fu   =   new   org.apache.commons.fileupload.DiskFileUpload();       
      //   设置允许用户上传文件大小,单位:字节   
      fu.setSizeMax(100000000);   
      //   maximum   size   that   will   be   stored   in   memory?   
      //   设置最多只允许在内存中存储的数据,单位:字节   
      fu.setSizeThreshold(4096);   
      //   设置一旦文件大小超过getSizeThreshold()的值时数据存放在硬盘的目录   
      fu.setRepositoryPath("D:\temp");   
      //开始读取上传信息   
      List   fileItems   =   fu.parseRequest(request);   
      %>   
      <body   bgcolor="#FFFFFF"text="#000000"   leftmargin="0"topmargin="40"marginwidth="0"   marginheight="0">   
      <font   size="6"color="blue">文件列表:</font>   
      <center>   
      <table   cellpadding=0   cellspacing=1   border=1   width="100%">   
      <tr>   
      <td   bgcolor="#008080">文件名</td>   
      <td   bgcolor="#008080">大小</td>   
      </tr>   
      <%   
      //   依次处理每个上传的文件   
      Iterator   iter   =   fileItems.iterator();   
      while   (iter.hasNext())   {   
          org.apache.commons.fileupload.FileItem   item   =   (org.apache.commons.fileupload.FileItem)   iter.next();     
          //忽略其他不是文件域的所有表单信息   
          if   (!item.isFormField())   {   
            String   name   =   item.getName();   
                    
            long   size   =   item.getSize();   
            if((name==null||name.equals(""))   &&   size==0)   
            continue;   
      %>   
      <tr>   
      <td><%=item.getName()%></td>   
      <td><%=item.getSize()%></td>   
      </tr>   
      <%   
            //保存上传的文件到指定的目录   
            name   =   name.replace(':','_');   
            name   =   name.replace('\','_');   
              
            java.io.File   f1=new   java.io.File("F:\"+   name);                                           
            item.write(f1);                                                                                                                                                
          }   
      }   
      %>   
      </table>   
        
      <br/><br/>   
      <a   href="Upload.htm">返回上传页面</a>   
      </center>   
      </body>   
      </html> 
      

  3.   

    root cause是什么,
    debug是什么地方报出来的。客户端是什么,我碰到过flash的一个上传bug,它不符合multipart boundary标准