org.springframework.web.filter
Class HiddenHttpMethodFilter
java.lang.Object
org.springframework.web.filter.GenericFilterBean
org.springframework.web.filter.OncePerRequestFilter
org.springframework.web.filter.HiddenHttpMethodFilter
- All Implemented Interfaces:
- javax.servlet.Filter, BeanNameAware, DisposableBean, InitializingBean, ServletContextAware
public class HiddenHttpMethodFilter
- extends OncePerRequestFilter
Servlet 2.3/2.4 Filter that converts posted method parameters into HTTP methods, retrievable
via HttpServletRequest.getMethod(). Since browsers currently only support GET and POST, a common technique -
used by the Prototype library, for instance - is to use a normal POST with an additional hidden form field
(_method) to pass the "real" HTTP method. This filter reads that parameter, and changes of HttpServletRequestWrapper.getMethod() accordingly.
The name of the request parameter defaults to _method, but can be changed via the methodParam property.
- Since:
- 3.0
- Author:
- Arjen Poutsma
|
Method Summary |
protected void |
doFilterInternal(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response,
javax.servlet.FilterChain filterChain)
Same contract as for doFilter, but guaranteed to be
just invoked once per request. |
void |
setMethodParam(java.lang.String methodParam)
Set the parameter name to look for HTTP methods. |
| Methods inherited from class org.springframework.web.filter.GenericFilterBean |
addRequiredProperty, afterPropertiesSet, destroy, getFilterConfig, getFilterName, getServletContext, init, initBeanWrapper, initFilterBean, setBeanName, setServletContext |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
DEFAULT_METHOD_PARAM
public static final java.lang.String DEFAULT_METHOD_PARAM
- Default method parameter, i.e.
_method.
- See Also:
- Constant Field Values
HiddenHttpMethodFilter
public HiddenHttpMethodFilter()
setMethodParam
public void setMethodParam(java.lang.String methodParam)
- Set the parameter name to look for HTTP methods.
- See Also:
DEFAULT_METHOD_PARAM
doFilterInternal
protected void doFilterInternal(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response,
javax.servlet.FilterChain filterChain)
throws javax.servlet.ServletException,
java.io.IOException
- Description copied from class:
OncePerRequestFilter
- Same contract as for
doFilter, but guaranteed to be
just invoked once per request. Provides HttpServletRequest and
HttpServletResponse arguments instead of the default ServletRequest
and ServletResponse ones.
- Specified by:
doFilterInternal in class OncePerRequestFilter
- Throws:
javax.servlet.ServletException
java.io.IOException