close

Filter

loading table of contents...

Content Application Developer Manual / Version 2110

Table Of Contents

4.3.1.7 HTTP Method Overriding

Using the @RequestMapping annotation, it is straightforward to define REST APIs using a richer set of HTTP methods to specify the semantics of each operation, for example GET, POST, PUT, and DELETE.

To maintain compatibility with clients which support only GET and POST such as older browsers, Spring provides a filter org.springframework.web.filter.HiddenHttpMethodFilter to effectively tunnel any HTTP method through a POST request. If you intend to make use of HTTP methods other than GET and POST in your handler mappings, configure the HiddenHttpMethodFilter via Spring.

With this filter in place, to signal the use of a particular HTTP method from the client, you may send a POST request with an additional parameter indicating the HTTP method to use. By default, the filter expects a parameter named _method. Note that only POST requests will be handled by this filter.

<form action="${url}" method="POST">
  <input type="hidden" name="_method" value="PUT"/>

  ...
</form>

Of course, clients supporting the HTTP method PUT, may send a PUT request directly, without adding the _method parameter.

Search Results

Table Of Contents
warning

Your Internet Explorer is no longer supported.

Please use Mozilla Firefox, Google Chrome, or Microsoft Edge.