I’m trying to send parameters with PUT from JavaScript to a Spring application. Here is the @RequestMapping in a Spring Controller:
@RequestMapping(value = "toggle-paid-action", method = RequestMethod.PUT)
@ResponseBody
public final String togglePaid(@RequestParam final int year,
@RequestParam final String docType, @RequestParam final int number) {
And here the JavaScript snippet that is supposed to send those parameters.
Ext.Ajax.request({
params: {year: year, docType: docType, number: number},
url: 'toggle-paid-action',
method: 'PUT',
However, I get a “400 Bad Request” every time with description “The request sent by the client was syntactically incorrect ()”.
If I check with Firebug, there is a PUT tab with all my parameters, and the parameters are correctly spelled since if I switch from PUT to POST on both sides everything works.
I was wondering what could be the problem, is PUT limited to @PathVariable parameters, or it can send also POST-like parameters?
I suppose you can’t pass parameters to spring using request method PUT as there is a restriction in the servlet API. You can only work with PUT methods implementing a restful service, passing data as the request body, in other cases (like Spring MVC Databinding) PUT won’t work.
see SpringMVC is not recognizing request body parameters if using PUT
JIRA:
https://jira.springsource.org/browse/SPR-7414