|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.springframework.web.multipart.commons.CommonsMultipartResolver
MultipartResolver implementation for Jakarta Commons FileUpload.
Provides maximumFileSize, maximumInMemorySize, and headerEncoding settings as bean properties; see respective DiskFileUpload properties (sizeMax, sizeThreshold, headerEncoding) for details in terms of defaults and accepted values.
Saves temporary files to the servlet container's temporary directory. Needs to be initialized either by an application context or via the constructor that takes a ServletContext (for standalone usage).
CommonsMultipartResolver(ServletContext)
,
CommonsMultipartFile
,
DiskFileUpload
Field Summary | |
protected org.apache.commons.logging.Log |
logger
|
Constructor Summary | |
CommonsMultipartResolver()
Constructor for use as bean. |
|
CommonsMultipartResolver(javax.servlet.ServletContext servletContext)
Constructor for standalone usage. |
Method Summary | |
void |
cleanupMultipart(MultipartHttpServletRequest request)
Cleanup any resources used for the multipart handling, like a storage for the uploaded files. |
protected java.lang.String |
determineEncoding(javax.servlet.http.HttpServletRequest request)
Determine the encoding for the given request. |
org.apache.commons.fileupload.DiskFileUpload |
getFileUpload()
Return the underlying org.apache.commons.fileupload.DiskFileUpload instance. |
boolean |
isMultipart(javax.servlet.http.HttpServletRequest request)
Determine if the request contains multipart content. |
protected org.apache.commons.fileupload.DiskFileUpload |
newFileUpload()
Initialize the underlying org.apache.commons.fileupload.DiskFileUpload instance. |
MultipartHttpServletRequest |
resolveMultipart(javax.servlet.http.HttpServletRequest request)
Wrap the servlet request inside a MultipartHttpServletRequest. |
void |
setDefaultEncoding(java.lang.String defaultEncoding)
Set the default character encoding to use for parsing requests, to be applied to headers of individual parts and to form fields. |
void |
setMaxInMemorySize(int maxInMemorySize)
Set the maximum allowed size (in bytes) before uploads are written to disk. |
void |
setMaxUploadSize(long maxUploadSize)
Set the maximum allowed size (in bytes) before uploads are refused. |
void |
setServletContext(javax.servlet.ServletContext servletContext)
Set the ServletContext that this object runs in. |
void |
setUploadTempDir(Resource uploadTempDir)
Set the temporary directory where uploaded files get stored. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
protected final org.apache.commons.logging.Log logger
Constructor Detail |
public CommonsMultipartResolver()
setServletContext(javax.servlet.ServletContext)
,
ServletContextAware
,
WebApplicationContext
public CommonsMultipartResolver(javax.servlet.ServletContext servletContext)
servletContext
- the ServletContext to useMethod Detail |
protected org.apache.commons.fileupload.DiskFileUpload newFileUpload()
public org.apache.commons.fileupload.DiskFileUpload getFileUpload()
public void setMaxUploadSize(long maxUploadSize)
maxUploadSize
- the maximum upload size allowedFileUploadBase.setSizeMax(long)
public void setMaxInMemorySize(int maxInMemorySize)
maxInMemorySize
- the maximum in memory size allowedDiskFileUpload.setSizeThreshold(int)
public void setDefaultEncoding(java.lang.String defaultEncoding)
If the request specifies a character encoding itself, the request encoding will override this setting. This also allows for generically overriding the character encoding in a filter that invokes the ServletRequest.setCharacterEncoding method.
defaultEncoding
- the character encoding to usedetermineEncoding(javax.servlet.http.HttpServletRequest)
,
ServletRequest.getCharacterEncoding()
,
ServletRequest.setCharacterEncoding(java.lang.String)
,
WebUtils.DEFAULT_CHARACTER_ENCODING
,
FileUploadBase.setHeaderEncoding(java.lang.String)
public void setUploadTempDir(Resource uploadTempDir) throws java.io.IOException
java.io.IOException
WebUtils.TEMP_DIR_CONTEXT_ATTRIBUTE
public void setServletContext(javax.servlet.ServletContext servletContext)
ServletContextAware
Invoked after population of normal bean properties but before an init callback like InitializingBean's afterPropertiesSet or a custom init-method. Invoked after ApplicationContextAware's setApplicationContext.
setServletContext
in interface ServletContextAware
servletContext
- ServletContext object to be used by this objectpublic boolean isMultipart(javax.servlet.http.HttpServletRequest request)
MultipartResolver
Will typically check for content type "multipart/form-data", but the actually accepted requests might depend on the capabilities of the resolver implementation.
isMultipart
in interface MultipartResolver
request
- the servlet request to be evaluated
true
if the request contains multipart content;
false
otherwisepublic MultipartHttpServletRequest resolveMultipart(javax.servlet.http.HttpServletRequest request) throws MultipartException
MultipartResolver
resolveMultipart
in interface MultipartResolver
request
- the servlet request to wrap (must be of a multipart content type)
MultipartException
- if the servlet request is not multipart, or if
implementation-specific problems are encountered (such as exceeding file size limits)protected java.lang.String determineEncoding(javax.servlet.http.HttpServletRequest request)
The default implementation checks the request encoding, falling back to the default encoding specified for this resolver.
request
- current HTTP request
ServletRequest.getCharacterEncoding()
,
setDefaultEncoding(java.lang.String)
public void cleanupMultipart(MultipartHttpServletRequest request)
MultipartResolver
cleanupMultipart
in interface MultipartResolver
request
- the request to cleanup resources for
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |