I would like to update my REST-Webservice by providing different Accept header values ββfor different versions (see http://barelyenough.org/blog/2008/05/versioning-rest-web-services/ ).
The problem is that this is not possible using Spring MVC 3.
My controller is as follows:
@Controller @RequestMapping("test") public class RestController { @RequestMapping(method = RequestMethod.GET, produces = "application/vnd.example.item-v1+json") @ResponseBody public ItemV1 getItem() { return new ItemV1(); } @RequestMapping(method = RequestMethod.GET, produces = "application/vnd.example.item-v2+json") @ResponseBody public ItemV2 getItem2() { return new ItemV2(); } }
When I try to access one of these methods, I get an exception:
java.lang.IllegalStateException: Ambiguous handler methods mapped for HTTP path '/test'
Am I missing something, or is this not possible with Spring MVC? I know this is possible with JAX-RS ...
Felix source share