清华大佬耗费三个月吐血整理的几百G的资源,免费分享!....>>>
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); } }