struts2上传:
在上传过程中关闭浏览器,
然后再打开浏览器重新上传,上传失败
struts2自动跳转到input  的result
error:Processing of multipart/form-data request failed. Stream ended unexpectedly
请struts2高手解答下原因及处理方法 谢谢。

解决方案 »

  1.   

    不是吧     应该不会出现这样的问题啊  
    我测试过我自己的上传   
    上传中间把浏览器关掉   
    在重新上传不会出现你那样的问题
    给你一段上传代码   你试试private File upload;// 封装上传文件
    private String uploadFileName;// 设置上传文件的文件名
    private String uploadContentType;// 上传文件的类型
    public File getUpload() {
                return upload;
    }public void setUpload(File upload) {
            this.upload = upload;
    }public String getUploadFileName() {
            return uploadFileName;
    }public void setUploadFileName(String uploadFileName) {
            this.uploadFileName = uploadFileName;
    }public String getUploadContentType() {
            return uploadContentType;
    }public void setUploadContentType(String uploadContentType) {
            this.uploadContentType = uploadContentType;
    }
    /**
             * xml文件上传
             *
             * @return
             * @throws Exception
             */
            public String xmlUpload() {
                    if (this.getUpload() == null) {
                            this.addActionError("不允许上传空文件,请您重新上传!");
                            return "commonPage";
                    }
                    FileOutputStream fos = null;
                    String basePathfile = 你要上传的文件路径 + getUploadFileName();
                    try {
                            fos = new FileOutputStream(basePathfile);
                    } catch (FileNotFoundException e) {
                            e.printStackTrace();
                    }
                    FileInputStream fis = null;
                    try {
                            fis = new FileInputStream(getUpload());
                    } catch (FileNotFoundException e) {
                            e.printStackTrace();
                    }
                    byte[] buffer = new byte[1024];
                    int len = 0;
                    try {
                            while ((len = fis.read(buffer)) > 0) {
                                    fos.write(buffer, 0, len);
                            }
                    } catch (IOException e) {
                            e.printStackTrace();
                    }
                    try {
                            fos.flush();
                            fos.close();
                            fis.close();
                    } catch (IOException e) {
                            e.printStackTrace();
                    }
                    System.out.println("导入完成");
                    return SUCCESS;
            }
      

  2.   

    我第一个测试的是   JDK  
    50多M    哪有那么快啊 
    第二个文件是完全上传完了的   
    没有一点问题
      

  3.   


    你的fileupload是什么版本的
      

  4.   

    那就不知道了
    <script>
    alert("那就不知道了!!");
    <script>
    看看你的页面
      

  5.   


    终于找到问题了,我的action是用spring管理的,就出现了这个问题,
    把spring管理去掉就好用了,但具体原因还没搞清楚。