Spring MVC 3: Is consumes supposed to disambiguate request mappings?
spring, spring-mvc
Solution
This has been resolved by Marten Deinum on the Spring Forum (here):
You should change both the HandlerMapping as well as the HandlerAdapter (use the RequestMappingHandlerAdapter).
In theory it should work if it doesn't feel free to register an issue.
The solution to this problem was to use the correct HandlerMapping and HandlerAdapter in my servlet configuration:
<bean class="org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping"/>
<bean class="org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter"/>
Thanks Marten.
Problem
I have two request mappings in a Spring MVC 3 application, one which takes `json` and `xml`, and another that takes `application/x-www-form-urlencoded` data. Example: ``` @RequestMapping(value={"/v1/foos"}, method = RequestMethod.POST, consumes={"application/json", "application/xml"}) public FooDTO createFoo(@RequestBody FooDTO requestDTO) throws Exception { ... } @RequestMapping(value={"/v1/foos"}, method = RequestMethod.POST, consumes="application/x-www-form-urlencoded") public FooDTO createFooWithForm(@ModelAttribute FooDTO requestDTO) throws Exception { ... } ``` I expected that the different `consumes` parameter makes each request unique, though I get an `java.lang.IllegalStateException: Ambiguous handler methods mapped...`. Should `consumes` and `produces` makes requests unique? Any ideas? Edit 1: To add weight to this, if you set the `content-type` in the header rather than using `consumes`, this actually works and makes them unique: `headers="content-type=application/x-www-form-urlencoded`. Perhaps there is a bug with `consumes`? Edit 2: We're using Spring 3.1.1.RELEASE.