public class

HiddenHttpMethodFilter

extends OncePerRequestFilter
java.lang.Object
   ↳ org.springframework.web.filter.GenericFilterBean
     ↳ org.springframework.web.filter.OncePerRequestFilter
       ↳ org.springframework.web.filter.HiddenHttpMethodFilter

Class Overview

javax.servlet.Filter that converts posted method parameters into HTTP methods, retrievable via 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 along. This filter reads that parameter and changes the getMethod() return value accordingly.

The name of the request parameter defaults to _method, but can be adapted via the 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 MultipartFilter before this HiddenHttpMethodFilter in your web.xml filter chain.

Summary

Constants
String DEFAULT_METHOD_PARAM Default method parameter: _method
[Expand]
Inherited Constants
From class org.springframework.web.filter.OncePerRequestFilter
[Expand]
Inherited Fields
From class org.springframework.web.filter.GenericFilterBean
Public Constructors
HiddenHttpMethodFilter()
Public Methods
void setMethodParam(String methodParam)
Set the parameter name to look for HTTP methods.
Protected Methods
void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain)
Same contract as for doFilter, but guaranteed to be just invoked once per request.
[Expand]
Inherited Methods
From class org.springframework.web.filter.OncePerRequestFilter
From class org.springframework.web.filter.GenericFilterBean
From class java.lang.Object
From interface javax.servlet.Filter
From interface org.springframework.beans.factory.BeanNameAware
From interface org.springframework.beans.factory.DisposableBean
From interface org.springframework.beans.factory.InitializingBean
From interface org.springframework.context.EnvironmentAware
From interface org.springframework.web.context.ServletContextAware

Constants

public static final String DEFAULT_METHOD_PARAM

Default method parameter: _method

Constant Value: "_method"

Public Constructors

public HiddenHttpMethodFilter ()

Public Methods

public void setMethodParam (String methodParam)

Set the parameter name to look for HTTP methods.

Protected Methods

protected void doFilterInternal (HttpServletRequest request, HttpServletResponse response, FilterChain filterChain)

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.

Throws
IOException
ServletException