上载文件停止,并在套接字异常上出现意外的 EOF 读取
2022-09-02 10:50:51
有时,当我尝试在我的远程vps上上传文件时,我得到这个异常(上传过程停止在60%)
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
ERR_CONNECTION_ABORTED
我在春季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;
那么如何解决这个问题呢?