Portlet version of Spring's multipart resolution strategy for file uploads
as defined in RFC 1867.
Implementations are typically usable both within any application context
and standalone.
There is one concrete implementation included in Spring:
There is no default resolver implementation used for Spring
org.springframework.web.portlet.DispatcherPortlet DispatcherPortlets ,
as an application might choose to parse its multipart requests itself. To
define an implementation, create a bean with the id
org.springframework.web.portlet.DispatcherPortlet.MULTIPART_RESOLVER_BEAN_NAME "portletMultipartResolver" in a DispatcherPortlet's application context. Such a resolver
gets applied to all requests handled by that DispatcherPortlet .
If a DispatcherPortlet detects a multipart request, it will
resolve it via the configured
org.springframework.web.multipart.MultipartResolver and pass on a
wrapped Portlet
ActionRequest .
org.springframework.web.portlet.mvc.Controller Controllers can then
cast their given request to the
MultipartActionRequest interface,
being able to access MultipartFiles . Note that this cast is
only supported in case of an actual multipart request.
public void handleActionRequest(ActionRequest request, ActionResponse response) {
MultipartActionRequest multipartRequest = (MultipartActionRequest) request;
MultipartFile multipartFile = multipartRequest.getFile("image");
...
}
Instead of direct access, command or form controllers can register a
org.springframework.web.multipart.support.ByteArrayMultipartFileEditor or
org.springframework.web.multipart.support.StringMultipartFileEditor with their data binder, to automatically apply multipart content to command
bean properties.
Note: There is hardly ever a need to access the
MultipartResolver itself from application code. It will simply
do its work behind the scenes, making MultipartActionRequests
available to controllers.
author: Juergen Hoeller since: 2.0 See Also: MultipartActionRequest See Also: org.springframework.web.multipart.MultipartFile See Also: CommonsPortletMultipartResolver See Also: org.springframework.web.multipart.support.ByteArrayMultipartFileEditor See Also: org.springframework.web.multipart.support.StringMultipartFileEditor See Also: org.springframework.web.portlet.DispatcherPortlet |