I can not get request body contents when request contains Content-Type=application/x-www-form-urlencoded.
I have following method for retrieving request body:
@RequestMapping(value = "/testRequestBody", method = RequestMethod.POST)
@ResponseBody
public String testRequestBody(@RequestBody String requestBody) {
return requestBody;
}
I am using restclient firefox plugin to test request. When I add Content-Type=application/x-www-form-urlencoded to request requestBody variable becomes empty despite I have text in the request body. When I remove Content-Type header, request body is populated with text.
UPD
This issue seems to be related to tomcat which is used to run spring container. When application/x-www-form-urlencoded request comes, it is parsed, parameters defined in the body become request parameters and body then is cleared.
I could access body parameters in the following manner:
@RequestMapping(value = "/testRequestBody", method = RequestMethod.POST)
@ResponseBody
public String testRequestBody(@RequestParam("paramName") String paramName) {
return requestParam;
}
How can I configure tomcat not to parse request and not to clear request body?