Springmvc文件上传监听
2018-07-20 来源:open-open
spring mvc CommonsMultipartResolver 文件上传监听。
/** * 重写 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); } }
标签: ssl
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com
特别注意:本站所有转载文章言论不代表本站观点!
本站所提供的图片等素材,版权归原作者所有,如需使用,请与原作者联系。
最新资讯
热门推荐