org.springframework.web.multipart.support.StandardServletMultipartResolver
和採用commons-fileupload的
org.springframework.web.multipart.commons.CommonsMultipartResolver
处理文件的上传须要重写接口MultipartResolver的parseRequest方法。
其涉及到的成员变量类型:
public CommonsFileUploadSupport() {this.fileItemFactory = newFileItemFactory(); <span style="white-space:pre"> </span>this.fileUpload = newFileUpload(getFileItemFactory()); } protected DiskFileItemFactory newFileItemFactory() { return new DiskFileItemFactory(); }
DiskFileItemFactory#createItem
public FileItem createItem(String fieldName, String contentType, boolean isFormField, String fileName) { DiskFileItem result = new DiskFileItem(fieldName, contentType, isFormField, fileName, sizeThreshold, repository); FileCleaningTracker tracker = getFileCleaningTracker(); if (tracker != null) { tracker.track(result.getTempFile(), this); } return result; }DiskFileItem#getOutputStream
public OutputStream getOutputStream() throws IOException { if (dfos == null) { File outputFile = getTempFile(); dfos = new DeferredFileOutputStream(sizeThreshold, outputFile); } return dfos; }