|
|
|
@ -1,5 +1,5 @@ |
|
|
|
/* |
|
|
|
/* |
|
|
|
* Copyright 2002-2012 the original author or authors. |
|
|
|
* Copyright 2002-2015 the original author or authors. |
|
|
|
* |
|
|
|
* |
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License"); |
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License"); |
|
|
|
* you may not use this file except in compliance with the License. |
|
|
|
* you may not use this file except in compliance with the License. |
|
|
|
@ -26,8 +26,10 @@ import javax.servlet.http.HttpServletRequest; |
|
|
|
* |
|
|
|
* |
|
|
|
* <p>There are two concrete implementations included in Spring, as of Spring 3.1: |
|
|
|
* <p>There are two concrete implementations included in Spring, as of Spring 3.1: |
|
|
|
* <ul> |
|
|
|
* <ul> |
|
|
|
* <li>{@link org.springframework.web.multipart.commons.CommonsMultipartResolver} for Jakarta Commons FileUpload |
|
|
|
* <li>{@link org.springframework.web.multipart.commons.CommonsMultipartResolver} |
|
|
|
* <li>{@link org.springframework.web.multipart.support.StandardServletMultipartResolver} for Servlet 3.0 Part API |
|
|
|
* for Apache Commons FileUpload |
|
|
|
|
|
|
|
* <li>{@link org.springframework.web.multipart.support.StandardServletMultipartResolver} |
|
|
|
|
|
|
|
* for the Servlet 3.0+ Part API |
|
|
|
* </ul> |
|
|
|
* </ul> |
|
|
|
* |
|
|
|
* |
|
|
|
* <p>There is no default resolver implementation used for Spring |
|
|
|
* <p>There is no default resolver implementation used for Spring |
|
|
|
@ -38,14 +40,11 @@ import javax.servlet.http.HttpServletRequest; |
|
|
|
* application context. Such a resolver gets applied to all requests handled |
|
|
|
* application context. Such a resolver gets applied to all requests handled |
|
|
|
* by that {@link org.springframework.web.servlet.DispatcherServlet}. |
|
|
|
* by that {@link org.springframework.web.servlet.DispatcherServlet}. |
|
|
|
* |
|
|
|
* |
|
|
|
* <p>If a {@link org.springframework.web.servlet.DispatcherServlet} detects |
|
|
|
* <p>If a {@link org.springframework.web.servlet.DispatcherServlet} detects a |
|
|
|
* a multipart request, it will resolve it via the configured |
|
|
|
* multipart request, it will resolve it via the configured {@link MultipartResolver} |
|
|
|
* {@link MultipartResolver} and pass on a |
|
|
|
* and pass on a wrapped {@link javax.servlet.http.HttpServletRequest}. Controllers |
|
|
|
* wrapped {@link javax.servlet.http.HttpServletRequest}. |
|
|
|
* can then cast their given request to the {@link MultipartHttpServletRequest} |
|
|
|
* Controllers can then cast their given request to the |
|
|
|
* interface, which allows for access to any {@link MultipartFile MultipartFiles}. |
|
|
|
* {@link MultipartHttpServletRequest} |
|
|
|
|
|
|
|
* interface, which permits access to any |
|
|
|
|
|
|
|
* {@link MultipartFile MultipartFiles}. |
|
|
|
|
|
|
|
* Note that this cast is only supported in case of an actual multipart request. |
|
|
|
* Note that this cast is only supported in case of an actual multipart request. |
|
|
|
* |
|
|
|
* |
|
|
|
* <pre class="code"> |
|
|
|
* <pre class="code"> |
|
|
|
@ -58,23 +57,19 @@ import javax.servlet.http.HttpServletRequest; |
|
|
|
* Instead of direct access, command or form controllers can register a |
|
|
|
* Instead of direct access, command or form controllers can register a |
|
|
|
* {@link org.springframework.web.multipart.support.ByteArrayMultipartFileEditor} |
|
|
|
* {@link org.springframework.web.multipart.support.ByteArrayMultipartFileEditor} |
|
|
|
* or {@link org.springframework.web.multipart.support.StringMultipartFileEditor} |
|
|
|
* or {@link org.springframework.web.multipart.support.StringMultipartFileEditor} |
|
|
|
* with their data binder, to automatically apply multipart content to command |
|
|
|
* with their data binder, to automatically apply multipart content to form |
|
|
|
* bean properties. |
|
|
|
* bean properties. |
|
|
|
* |
|
|
|
* |
|
|
|
* <p>As an alternative to using a |
|
|
|
* <p>As an alternative to using a {@link MultipartResolver} with a |
|
|
|
* {@link MultipartResolver} with a |
|
|
|
|
|
|
|
* {@link org.springframework.web.servlet.DispatcherServlet}, |
|
|
|
* {@link org.springframework.web.servlet.DispatcherServlet}, |
|
|
|
* a {@link org.springframework.web.multipart.support.MultipartFilter} can be |
|
|
|
* a {@link org.springframework.web.multipart.support.MultipartFilter} can be |
|
|
|
* registered in {@code web.xml}. It will delegate to a corresponding |
|
|
|
* registered in {@code web.xml}. It will delegate to a corresponding |
|
|
|
* {@link MultipartResolver} bean in the root |
|
|
|
* {@link MultipartResolver} bean in the root application context. This is mainly |
|
|
|
* application context. This is mainly intended for applications that do not |
|
|
|
* intended for applications that do not use Spring's own web MVC framework. |
|
|
|
* use Spring's own web MVC framework. |
|
|
|
|
|
|
|
* |
|
|
|
* |
|
|
|
* <p>Note: There is hardly ever a need to access the |
|
|
|
* <p>Note: There is hardly ever a need to access the {@link MultipartResolver} |
|
|
|
* {@link MultipartResolver} itself |
|
|
|
* itself from application code. It will simply do its work behind the scenes, |
|
|
|
* from application code. It will simply do its work behind the scenes, |
|
|
|
* making {@link MultipartHttpServletRequest MultipartHttpServletRequests} |
|
|
|
* making |
|
|
|
|
|
|
|
* {@link MultipartHttpServletRequest MultipartHttpServletRequests} |
|
|
|
|
|
|
|
* available to controllers. |
|
|
|
* available to controllers. |
|
|
|
* |
|
|
|
* |
|
|
|
* @author Juergen Hoeller |
|
|
|
* @author Juergen Hoeller |
|
|
|
@ -101,8 +96,8 @@ public interface MultipartResolver { |
|
|
|
/** |
|
|
|
/** |
|
|
|
* Parse the given HTTP request into multipart files and parameters, |
|
|
|
* Parse the given HTTP request into multipart files and parameters, |
|
|
|
* and wrap the request inside a |
|
|
|
* and wrap the request inside a |
|
|
|
* {@link org.springframework.web.multipart.MultipartHttpServletRequest} object |
|
|
|
* {@link org.springframework.web.multipart.MultipartHttpServletRequest} |
|
|
|
* that provides access to file descriptors and makes contained |
|
|
|
* object that provides access to file descriptors and makes contained |
|
|
|
* parameters accessible via the standard ServletRequest methods. |
|
|
|
* parameters accessible via the standard ServletRequest methods. |
|
|
|
* @param request the servlet request to wrap (must be of a multipart content type) |
|
|
|
* @param request the servlet request to wrap (must be of a multipart content type) |
|
|
|
* @return the wrapped servlet request |
|
|
|
* @return the wrapped servlet request |
|
|
|
|