Passing data in the body of a DELETE request

You can try adding the annotation @RequestBody to your Product argument.

But if you just need to pass version information, using a request param is more appropriate.

So add a new argument in your delete method @RequestParam("version") int version, and when calling the delete method pass a query param like ..ajax/products/123?version=1

As you said request param is not working for you in delete, can you post the exact url you used and the method signature ?


The problem is not a Spring problem, but a Tomcat problem.

By default, Tomcat will only parse arguments that are in the form style, when the HTTP method is POST (at least for version 7.0.54 that I checked but it's probably the same for all Tomcat 7 versions).

In order to be able to handle DELETE methods as well you need to set the parseBodyMethods attribute of the Tomcat Connector. The connector configuration is done in server.xml.

Your updated connector would most likely look like:

<Connector port="8080" protocol="HTTP/1.1" 
           connectionTimeout="20000"
           redirectPort="8443"
           parseBodyMethods="POST,PUT,DELETE"
           URIEncoding="UTF-8" />

Here is documentation page for configuring Tomcat connectors.

Once you setup Tomcat to parse the parameters, Spring will work just fine (although in your case you will probably need to remove @RequestBody from the controller method)