Thursday, April 19, 2012

Using both @RequestBody and @RequestParam together in spring mvc3

I am using spring-mvc 3.1.0.RELEASE and for some reason, mapping POST with query params and request body does not work.



Here is how my controller method looks:



  @RequestMapping(method = POST, value = "/post-to-me/") 
public void handlePost(
@RequestBody Content content,
@RequestParam("param1") String param1,
@RequestParam("param2") String param2
){
//do stuff
}


However, if I convert all the request params to path params, mapping works. Has anyone run into something similar?



Thanks!



EDIT:
"does not work" == 404 when I try doing, POST /post-to-me?param1=x&param2=y





1 comment: