Skip to content

Commit 0eabef0

Browse files
committed
added filter ordering comments (SPR-6594)
1 parent 2c9753a commit 0eabef0

File tree

2 files changed

+13
-9
lines changed

2 files changed

+13
-9
lines changed

org.springframework.web/src/main/java/org/springframework/web/filter/HiddenHttpMethodFilter.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,11 @@
3838
* <p>The name of the request parameter defaults to <code>_method</code>, but can be
3939
* changed via the {@link #setMethodParam(String) methodParam} property.
4040
*
41+
* <p><b>NOTE: This filter needs to run after multipart processing in case of a multipart
42+
* POST request, due to its inherent need for checking a POST body parameter.</b>
43+
* So typically, put a Spring {@link org.springframework.web.multipart.support.MultipartFilter}
44+
* <i>before</i> this HiddenHttpMethodFilter in your <code>web.xml</code> filter chain.
45+
*
4146
* @author Arjen Poutsma
4247
* @since 3.0
4348
*/

org.springframework.web/src/main/java/org/springframework/web/multipart/support/MultipartFilter.java

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2006 the original author or authors.
2+
* Copyright 2002-2010 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -17,7 +17,6 @@
1717
package org.springframework.web.multipart.support;
1818

1919
import java.io.IOException;
20-
2120
import javax.servlet.FilterChain;
2221
import javax.servlet.ServletException;
2322
import javax.servlet.http.HttpServletRequest;
@@ -46,9 +45,10 @@
4645
* for each call but rather return a reference to a pre-built instance.
4746
*
4847
* <p>Note: This filter is an <b>alternative</b> to using DispatcherServlet's
49-
* MultipartResolver support, for example for web applications with custom
50-
* web views that do not use Spring's web MVC. It should not be combined with
51-
* servlet-specific multipart resolution.
48+
* MultipartResolver support, for example for web applications with custom web views
49+
* which do not use Spring's web MVC, or for custom filters applied before a Spring MVC
50+
* DispatcherServlet (e.g. {@link org.springframework.web.filter.HiddenHttpMethodFilter}).
51+
* In any case, this filter should not be combined with servlet-specific multipart resolution.
5252
*
5353
* @author Juergen Hoeller
5454
* @since 08.10.2003
@@ -77,7 +77,7 @@ public void setMultipartResolverBeanName(String multipartResolverBeanName) {
7777
* root application context.
7878
*/
7979
protected String getMultipartResolverBeanName() {
80-
return multipartResolverBeanName;
80+
return this.multipartResolverBeanName;
8181
}
8282

8383

@@ -143,9 +143,8 @@ protected MultipartResolver lookupMultipartResolver() {
143143
if (logger.isDebugEnabled()) {
144144
logger.debug("Using MultipartResolver '" + getMultipartResolverBeanName() + "' for MultipartFilter");
145145
}
146-
WebApplicationContext wac =
147-
WebApplicationContextUtils.getRequiredWebApplicationContext(getServletContext());
148-
return (MultipartResolver) wac.getBean(getMultipartResolverBeanName(), MultipartResolver.class);
146+
WebApplicationContext wac = WebApplicationContextUtils.getRequiredWebApplicationContext(getServletContext());
147+
return wac.getBean(getMultipartResolverBeanName(), MultipartResolver.class);
149148
}
150149

151150
}

0 commit comments

Comments
 (0)