有时当我尝试上传一个文件在我的远程VPS我得到这个例外(以60%的上传proccess停止)上传文件停止与意外EOF读取插座异常
06-Jan-2016 11:59:36.801 SEVERE [http-nio-54000-exec-9] org.apache.catalina.core.StandardWrapperValve.invoke Servlet.service() for servlet [mvc-dispatcher] in context with path [] threw exception [Request processing failed;
nested exception is org.springframework.web.multipart.MultipartException: Could not parse multipart servlet request;
nested exception is org.apache.commons.fileupload.FileUploadBase$IOFileUploadException: Processing of multipart/form-data request failed. Unexpected EOF read on the socket]
with root cause
java.io.EOFException: Unexpected EOF read on the socket
和Google Chrome
的connextion丢失,如服务器关闭,我得到ERR_CONNECTION_ABORTED
我Spring MVC中上传文件中像这样
public void save_file(MultipartFile upfile , String path){
try {
File fichier = new File(path) ;
byte[] bytes = upfile.getBytes();
BufferedOutputStream stream = new BufferedOutputStream(new FileOutputStream(fichier));
stream.write(bytes);
stream.close();
System.out.println("You successfully uploaded " + upfile.getOriginalFilename() + "!");
} catch (Exception e) {
System.out.println("You failed to upload " + upfile.getOriginalFilename() + " => " + e.getMessage()); ;
}
}
我的控制器:
@RequestMapping(value = "/administration/upload", method = RequestMethod.POST)
public String Upload_AO_journal(
@ModelAttribute UploadForm uploadForm,
Model map , HttpServletRequest request, HttpSession session) throws ParseException, UnsupportedEncodingException {
我的豆
public class UploadForm {
...
public MultipartFile scan;
那么如何才能解决这个问题?
它对所有文件大小都失败,还是小文件成功?你能分享一下将这个请求映射到这个方法的Spring特定代码吗? – tdimmig
@tdimmig有时它会失败,有时它的大小相同,它是okey!我更新我的问题。 – Youssef
看看这个答案可以帮助你:http://stackoverflow.com/a/18543887/4056187 – robert