I'm working on simple Spring-MVC application and I love new Spring REST features. I'd like to use the same method to process regular form and JSON data. It seems to be a little tricky, however. For example, method
public @ResponseBody String process(@RequestBody Bean bean);
will work for JSON request (Content-type: application/json), and
public @ResponseBody String process(Bean bean);
will match request with Content-type: application/x-www-form-urlencoded.
These methods are obviously will have almost the same content, so I'd prefer to avoid such duplication. With Jersey it's possible with @Consumes
annotations, but I can't figure out how to do it with Spring.