Class Overview
Servlet 2.3 Filter that resolves multipart requests via a MultipartResolver.
in the root web application context.
Looks up the MultipartResolver in Spring's root web application context.
Supports a "multipartResolverBeanName" filter init-param in web.xml
;
the default bean name is "filterMultipartResolver". Looks up the MultipartResolver
on each request, to avoid initialization order issues (when using ContextLoaderServlet,
the root application context will get initialized after this filter).
MultipartResolver lookup is customizable: Override this filter's
lookupMultipartResolver
method to use a custom MultipartResolver
instance, for example if not using a Spring web application context.
Note that the lookup method should not create a new MultipartResolver instance
for each call but rather return a reference to a pre-built instance.
Note: This filter is an alternative to using DispatcherServlet's
MultipartResolver support, for example for web applications with custom web views
which do not use Spring's web MVC, or for custom filters applied before a Spring MVC
DispatcherServlet (e.g. HiddenHttpMethodFilter
).
In any case, this filter should not be combined with servlet-specific multipart resolution.
Summary
Public Methods |
void
|
setMultipartResolverBeanName(String multipartResolverBeanName)
Set the bean name of the MultipartResolver to fetch from Spring's
root application context.
|
Protected Methods |
void
|
doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain)
Check for a multipart request via this filter's MultipartResolver,
and wrap the original request with a MultipartHttpServletRequest if appropriate.
|
String
|
getMultipartResolverBeanName()
Return the bean name of the MultipartResolver to fetch from Spring's
root application context.
|
MultipartResolver
|
lookupMultipartResolver(HttpServletRequest request)
Look up the MultipartResolver that this filter should use,
taking the current HTTP request as argument.
|
MultipartResolver
|
lookupMultipartResolver()
Look for a MultipartResolver bean in the root web application context.
|
[Expand]
Inherited Methods |
From class
org.springframework.web.filter.OncePerRequestFilter
final
void
|
doFilter(ServletRequest request, ServletResponse response, FilterChain filterChain)
This doFilter implementation stores a request attribute for
"already filtered", proceeding without filtering again if the
attribute is already there.
|
abstract
void
|
doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain)
Same contract as for doFilter , but guaranteed to be
just invoked once per request.
|
String
|
getAlreadyFilteredAttributeName()
Return the name of the request attribute that identifies that a request
is already filtered.
|
boolean
|
shouldNotFilter(HttpServletRequest request)
Can be overridden in subclasses for custom filtering control,
returning true to avoid filtering of the given request.
|
|
From class
org.springframework.web.filter.GenericFilterBean
final
void
|
addRequiredProperty(String property)
Subclasses can invoke this method to specify that this property
(which must match a JavaBean property they expose) is mandatory,
and must be supplied as a config parameter.
|
void
|
afterPropertiesSet()
Calls the initFilterBean() method that might
contain custom initialization of a subclass.
|
void
|
destroy()
Subclasses may override this to perform custom filter shutdown.
|
final
FilterConfig
|
getFilterConfig()
Make the FilterConfig of this filter available, if any.
|
final
String
|
getFilterName()
Make the name of this filter available to subclasses.
|
final
ServletContext
|
getServletContext()
Make the ServletContext of this filter available to subclasses.
|
final
void
|
init(FilterConfig filterConfig)
Standard way of initializing this filter.
|
void
|
initBeanWrapper(BeanWrapper bw)
Initialize the BeanWrapper for this GenericFilterBean,
possibly with custom editors.
|
void
|
initFilterBean()
Subclasses may override this to perform custom initialization.
|
final
void
|
setBeanName(String beanName)
Stores the bean name as defined in the Spring bean factory.
|
void
|
setEnvironment(Environment environment)
Set the Environment that this object runs in.
Any environment set here overrides the DefaultWebEnvironment
provided by default.
|
final
void
|
setServletContext(ServletContext servletContext)
Stores the ServletContext that the bean factory runs in.
|
|
From class
java.lang.Object
Object
|
clone()
|
boolean
|
equals(Object arg0)
|
void
|
finalize()
|
final
Class<?>
|
getClass()
|
int
|
hashCode()
|
final
void
|
notify()
|
final
void
|
notifyAll()
|
String
|
toString()
|
final
void
|
wait()
|
final
void
|
wait(long arg0, int arg1)
|
final
void
|
wait(long arg0)
|
|
From interface
javax.servlet.Filter
abstract
void
|
destroy()
|
abstract
void
|
doFilter(ServletRequest arg0, ServletResponse arg1, FilterChain arg2)
|
abstract
void
|
init(FilterConfig arg0)
|
|
From interface
org.springframework.beans.factory.BeanNameAware
abstract
void
|
setBeanName(String name)
Set the name of the bean in the bean factory that created this bean.
|
|
From interface
org.springframework.beans.factory.DisposableBean
abstract
void
|
destroy()
Invoked by a BeanFactory on destruction of a singleton.
|
|
From interface
org.springframework.beans.factory.InitializingBean
abstract
void
|
afterPropertiesSet()
Invoked by a BeanFactory after it has set all bean properties supplied
(and satisfied BeanFactoryAware and ApplicationContextAware).
|
|
From interface
org.springframework.context.EnvironmentAware
|
From interface
org.springframework.web.context.ServletContextAware
abstract
void
|
setServletContext(ServletContext servletContext)
Set the ServletContext that this object runs in.
|
|
Constants
public
static
final
String
DEFAULT_MULTIPART_RESOLVER_BEAN_NAME
Constant Value:
"filterMultipartResolver"
Public Constructors
public
MultipartFilter
()
Public Methods
public
void
setMultipartResolverBeanName
(String multipartResolverBeanName)
Set the bean name of the MultipartResolver to fetch from Spring's
root application context. Default is "filterMultipartResolver".
Protected Methods
protected
void
doFilterInternal
(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain)
Check for a multipart request via this filter's MultipartResolver,
and wrap the original request with a MultipartHttpServletRequest if appropriate.
All later elements in the filter chain, most importantly servlets, benefit
from proper parameter extraction in the multipart case, and are able to cast to
MultipartHttpServletRequest if they need to.
protected
String
getMultipartResolverBeanName
()
Return the bean name of the MultipartResolver to fetch from Spring's
root application context.
protected
MultipartResolver
lookupMultipartResolver
(HttpServletRequest request)
Look up the MultipartResolver that this filter should use,
taking the current HTTP request as argument.
Default implementation delegates to the lookupMultipartResolver
without arguments.
Returns
- the MultipartResolver to use
protected
MultipartResolver
lookupMultipartResolver
()
Look for a MultipartResolver bean in the root web application context.
Supports a "multipartResolverBeanName" filter init param; the default
bean name is "filterMultipartResolver".
This can be overridden to use a custom MultipartResolver instance,
for example if not using a Spring web application context.
Returns
- the MultipartResolver instance, or
null
if none found