类 MultipartFilter

  • 所有已实现的接口:
    Filter, Aware, BeanNameAware, DisposableBean, InitializingBean, EnvironmentAware, EnvironmentCapable, ServletContextAware

    public class MultipartFilter
    extends OncePerRequestFilter
    Servlet 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".

    If no MultipartResolver bean is found, this filter falls back to a default MultipartResolver: StandardServletMultipartResolver for Servlet 3.0, based on a multipart-config section in web.xml. Note however that at present the Servlet specification only defines how to enable multipart configuration on a Servlet and as a result multipart request processing is likely not possible in a Filter unless the Servlet container provides a workaround such as Tomcat's "allowCasualMultipartParsing" property.

    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.

    从以下版本开始:
    08.10.2003
    作者:
    Juergen Hoeller
    另请参阅:
    setMultipartResolverBeanName(java.lang.String), lookupMultipartResolver(javax.servlet.http.HttpServletRequest), MultipartResolver, DispatcherServlet