diff --git a/org.springframework.web/src/main/java/org/springframework/web/filter/HiddenHttpMethodFilter.java b/org.springframework.web/src/main/java/org/springframework/web/filter/HiddenHttpMethodFilter.java index 81551670ab0..667b8e546c5 100644 --- a/org.springframework.web/src/main/java/org/springframework/web/filter/HiddenHttpMethodFilter.java +++ b/org.springframework.web/src/main/java/org/springframework/web/filter/HiddenHttpMethodFilter.java @@ -38,6 +38,11 @@ import org.springframework.util.StringUtils; *

The name of the request parameter defaults to _method, but can be * changed via the {@link #setMethodParam(String) methodParam} property. * + *

NOTE: This filter needs to run after multipart processing in case of a multipart + * POST request, due to its inherent need for checking a POST body parameter. + * So typically, put a Spring {@link org.springframework.web.multipart.support.MultipartFilter} + * before this HiddenHttpMethodFilter in your web.xml filter chain. + * * @author Arjen Poutsma * @since 3.0 */ diff --git a/org.springframework.web/src/main/java/org/springframework/web/multipart/support/MultipartFilter.java b/org.springframework.web/src/main/java/org/springframework/web/multipart/support/MultipartFilter.java index b5c770bf85d..c151aaa81b5 100644 --- a/org.springframework.web/src/main/java/org/springframework/web/multipart/support/MultipartFilter.java +++ b/org.springframework.web/src/main/java/org/springframework/web/multipart/support/MultipartFilter.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2006 the original author or authors. + * Copyright 2002-2010 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,7 +17,6 @@ package org.springframework.web.multipart.support; import java.io.IOException; - import javax.servlet.FilterChain; import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; @@ -46,9 +45,10 @@ import org.springframework.web.multipart.MultipartResolver; * 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 that do not use Spring's web MVC. It should not be combined with - * servlet-specific multipart resolution. + * 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. {@link org.springframework.web.filter.HiddenHttpMethodFilter}). + * In any case, this filter should not be combined with servlet-specific multipart resolution. * * @author Juergen Hoeller * @since 08.10.2003 @@ -77,7 +77,7 @@ public class MultipartFilter extends OncePerRequestFilter { * root application context. */ protected String getMultipartResolverBeanName() { - return multipartResolverBeanName; + return this.multipartResolverBeanName; } @@ -143,9 +143,8 @@ public class MultipartFilter extends OncePerRequestFilter { if (logger.isDebugEnabled()) { logger.debug("Using MultipartResolver '" + getMultipartResolverBeanName() + "' for MultipartFilter"); } - WebApplicationContext wac = - WebApplicationContextUtils.getRequiredWebApplicationContext(getServletContext()); - return (MultipartResolver) wac.getBean(getMultipartResolverBeanName(), MultipartResolver.class); + WebApplicationContext wac = WebApplicationContextUtils.getRequiredWebApplicationContext(getServletContext()); + return wac.getBean(getMultipartResolverBeanName(), MultipartResolver.class); } }