将文件上传到Spring时,net :: ERR_CONNECTION_ABORTED的可能原因是什么?

我正在使用plupload(plupload.com)jQuery插件将AJAX图像文件发送到Java Spring服务器。 我尝试过服务器端RESTful Controller Endpoint的不同实现。 我附加了处理文件上传URL的具体方法。 任何帮助将非常感谢。 谢谢。

@RequestMapping(value = "/pictureUpload", method = RequestMethod.POST ) public @ResponseBody String productPictureUploadPost(@RequestBody MultipartFile multipartFile) { HomeController.logger.info("In method productPictureUploadPost in SettingsPanelController. : Entering"); String orgName = multipartFile.getOriginalFilename(); String filePath = "/my_uploads/" + orgName; File dest = new File(filePath); try { multipartFile.transferTo(dest); } catch (IllegalStateException e) { e.printStackTrace(); return "File uploaded failed:" + orgName; } catch (IOException e) { e.printStackTrace(); return "File uploaded failed:" + orgName; } HomeController.logger.info("In method productPictureUploadPost in SettingsPanelController. Exiting : " + "File uploaded:" + orgName); return "File uploaded:" + orgName; } 

我还附加了servlet .xml多部分解析器声明。

  

在客户端,我有一个调用的插件文件,如下所示。

 $(document).ready(function() { $("#uploader").plupload({ // General settings runtimes: 'html5,flash,silverlight,html4', url: "/pictureUpload", // Maximum file size max_file_size: '1000mb', // User can upload no more then 20 files in one go (sets multiple_queues to false) max_file_count: 3, // Specify what files to browse for filters: [ { title: "Image files", extensions: "jpg,jpeg,gif,png" } ], // Rename files by clicking on their titles rename: true, // Sort files sortable: true, // Enable ability to drag'n'drop files onto the widget (currently only HTML5 supports that) dragdrop: true, // Views to activate views: { list: true, thumbs: true, // Show thumbs active: 'thumbs' }, // Flash settings flash_swf_url : 'http://rawgithub.com/moxiecode/moxie/master/bin/flash/Moxie.cdn.swf', // Silverlight settings silverlight_xap_url : 'http://rawgithub.com/moxiecode/moxie/master/bin/silverlight/Moxie.cdn.xap' }); }); 

在文件上载的上下文中,当HTTP服务器未完全读取客户端的HTTP请求主体并中止连接中上载时,会发生net::ERR_CONNECTION_ABORTED 。 这通常发生在上传文件太大的情况下,服务器继续读取请求并提前失败是没有意义的。

中止连接意味着客户端在接收响应之前不会浪费上传文件的带宽,但会触发上述错误。

HTTP提供了早期连接终止, Expect: 100-continue请求标头和100 Continue response status,您可以在这里阅读: http : //benramsey.com/blog/2008/04/http-status-100 -继续/

不幸的是,大多数浏览器在文件上传期间不发送它( 哪些浏览器发送期望:100-continue标题? )。

但是,由于您在客户端使用Flash / Silverlight进行上传,我建议您尝试将上传小部件发送到Expect: 100-continue到服务器。