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?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…