org.springframework.web.multipart.support
Class MultipartFilter

java.lang.Object
  extended byorg.springframework.web.filter.GenericFilterBean
      extended byorg.springframework.web.filter.OncePerRequestFilter
          extended byorg.springframework.web.multipart.support.MultipartFilter
All Implemented Interfaces:
Filter

public class MultipartFilter
extends OncePerRequestFilter

Servlet 2.3 Filter that resolves multipart requests via a MultipartResolver in the root web application context. Supports a "multipartResolverBeanName" filter init-param; the default bean name is "filterMultipartResolver".

MultipartResolver determination is customizable: Override this filter's getMultipartResolver method to use a custom MultipartResolver instance, for example if not using a Spring web application context.

Note: This filter is an alternative to using DispatcherServlet's MultipartResolver support, for example for web applications with custom web views that do not use Spring's web MVC. It should not be combined with servlet-specific multipart resolution.

Since:
08.10.2003
Author:
Juergen Hoeller
See Also:
MultipartResolver, DispatcherServlet

Field Summary
static String DEFAULT_MULTIPART_RESOLVER_BEAN_NAME
           
 
Fields inherited from class org.springframework.web.filter.OncePerRequestFilter
ALREADY_FILTERED_SUFFIX
 
Fields inherited from class org.springframework.web.filter.GenericFilterBean
logger
 
Constructor Summary
MultipartFilter()
           
 
Method Summary
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.
protected  String getMultipartResolverBeanName()
          Return the bean name of the MultipartResolver to fetch from Spring's root application context.
protected  void initFilterBean()
          Fetch a reference to the MultipartResolver via lookupMultipartResolver and stores it for use in this filter.
protected  MultipartResolver lookupMultipartResolver()
          Look for a MultipartResolver bean in the root web application context.
 void setMultipartResolverBeanName(String multipartResolverBeanName)
          Set the bean name of the MultipartResolver to fetch from Spring's root application context.
 
Methods inherited from class org.springframework.web.filter.OncePerRequestFilter
doFilter, getAlreadyFilteredAttributeName, shouldNotFilter
 
Methods inherited from class org.springframework.web.filter.GenericFilterBean
addRequiredProperty, destroy, getFilterConfig, getFilterName, getServletContext, init, initBeanWrapper, setFilterConfig
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_MULTIPART_RESOLVER_BEAN_NAME

public static final String DEFAULT_MULTIPART_RESOLVER_BEAN_NAME
See Also:
Constant Field Values
Constructor Detail

MultipartFilter

public MultipartFilter()
Method Detail

setMultipartResolverBeanName

public void setMultipartResolverBeanName(String multipartResolverBeanName)
Set the bean name of the MultipartResolver to fetch from Spring's root application context.


getMultipartResolverBeanName

protected String getMultipartResolverBeanName()
Return the bean name of the MultipartResolver to fetch from Spring's root application context.


initFilterBean

protected void initFilterBean()
                       throws ServletException
Fetch a reference to the MultipartResolver via lookupMultipartResolver and stores it for use in this filter.

Overrides:
initFilterBean in class GenericFilterBean
Throws:
ServletException - if subclass initialization fails
See Also:
lookupMultipartResolver()

lookupMultipartResolver

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

doFilterInternal

protected void doFilterInternal(HttpServletRequest request,
                                HttpServletResponse response,
                                FilterChain filterChain)
                         throws ServletException,
                                IOException
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.

Specified by:
doFilterInternal in class OncePerRequestFilter
Throws:
ServletException
IOException


Copyright (C) 2003-2004 The Spring Framework Project.