Maybe this is supposed to not work, but at least I’d like to understand why then. I am passing a simple val=somevalue in the PUT body but spring sends back a 400 Bad Request as it does not seem to recognise the val parameter.
Similar request works with POST. Could it be SpringMVC is not recognizing the PUT request body as source for parameters?
Content=-Type is set correctly to application/x-www-form-urlencoded in both cases.
The method that spring refuses to call is this:
@RequestMapping(value = "config/{key}", method = RequestMethod.PUT)
@ResponseBody
public void configUpdateCreate(final Model model, @PathVariable final String key, @RequestParam final String val,
final HttpServletResponse response) throws IOException
{
//...
}
For completeness, here is the jquery ajax call. I cannot see anything wrong with that. Client is Firefox 4 or Chrome, both show the same result.
$.ajax({
url:url,
type:'PUT',
data:'val=' + encodeURIComponent(configValue),
success: function(data) {...}
});
Any ideas?
I don’t know of a work around at this point, but here is the bug report that is a “Won’t Fix.” I’ve been fighting the same issue
https://jira.springsource.org/browse/SPR-7414
Update: Here is my fix. I’m using RequestBody annotation. Then using MultiValueMap.
http://static.springsource.org/spring/docs/3.0.5.RELEASE/reference/mvc.html#mvc-ann-requestbody