springmvc上传监听
/** * 重写 parseRequest方法 监听 */ @Override protected MultipartParsingResult parseRequest(HttpServletRequest request) throws MultipartException { System.out.println("MultipartParsingResult:--------------------------"+request); String encoding = determineEncoding(request); FileUpload fileUpload = prepareFileUpload(encoding); fileUpload.setFileSizeMax(-1); final HttpSession session = request.getSession(); fileUpload.setProgressListener(new ProgressListener() { @Override public void update(long pBytesRead, long pContentLength, int pItems) { try { Thread.sleep(5); } catch (InterruptedException e) { e.printStackTrace(); } session.setAttribute("pBytesRead", pBytesRead); } }); try { List<FileItem> fileItems = ((ServletFileUpload) fileUpload).parseRequest(request); return parseFileItems(fileItems, encoding); } catch (FileUploadBase.SizeLimitExceededException ex) { throw new MaxUploadSizeExceededException(fileUpload.getSizeMax(), ex); } catch (FileUploadException ex) { throw new MultipartException( "Could not parse multipart servlet request", ex); } }
郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。