KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I am running a Spring 3.1.2 application. I have a RESTful servlet with a number of methods. The GET methods are working fantastic ( @PathVariables matching, responses correctly marshalled to JSON or XML based on the Accept header, etc) 100% of the time. However the POST method is simply not working. After hours of messing around with converts and every other Spring aspect I could find (all tinkering reverted), I narrowed it do to the required field in @RequestParam . This is a simplified test method I've been using to investigate: @RequestMapping (value = "/bogus", method = POST) public @ResponseBody PassResponse bogus ( @RequestParam (value = "test", required = false) String test) { // Just some handy garbage objects that marshal to JSON/XML UserResponse user = new UserResponse (); user.setName (test); AccountDetail detail = new AccountDetail (user,null); return new PassResponse (detail); } required=false : everything works (parameter is received and interpreted). Exactly as I expect it to work required=true : (or not specified, since this is the default) I consistently get the message " MissingServletRequestParameterException: Required String parameter 'test' is not present " Client side view: required=true Request URL:http://localhost:8080/internal-project/rest/bogus Request Method:POST Status Code:400 Bad Request Request Headersview source Accept:application/json Connection:keep-alive Content-Length:12 Host:localhost:8080 Request Payload test=LALALAA Response Headersview source Connection:close Content-Length:971 Content-Type:text/html;charset=utf-8 Date:Wed, 24 Oct 2012 18:41:05 GMT Server:Apache-Coyote/1.1 required=false Request URL:http://localhost:8080/internal-project/rest/bogus Reque
Tags (comma-separated)
Save Edits
Cancel