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:
I expected that the different consumes parameter makes each request unique, though I get an java.lang.IllegalStateException: Ambiguous handler methods mapped....Code:@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 { ... }
Should consumes and produces makes requests unique? Any ideas?
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?
NOTE: We're using Spring 3.1.1.RELEASE.


Reply With Quote
