Update Mar.04 Thanks to @ewolff some of the points described below are now official feature requests. One (SPR-6928) is actually scheduled in Spring 3.1 (cool!). I’ve updated the post and added all open tickets. Please vote!
This post is somewhat a response to InfoQ’s Comparison of Spring MVC and JAX-RS.
Recently I have completed a migration from a JAX-RS implementation of a web service to Spring 3.0 MVC annotation-based @Controllers. The aforementioned post on InfoQ was published a few days after my migration so I’m dumping below the list of problems I had, along with solutions.
Full list of issues:
- Same relative paths in multiple controllers not supported
- @ExceptionHandler is controller-centric
- Standard content negotiation can’t respond with a fixed response type
- JSR 303 bean validation not applied in @Controllers
- Formatting responses (i.e. Date) not working when using Spring formatter annotations
Same relative paths in multiple @Controllers not supported
Consider two Controllers where I use a versioned URL and a web.xml file that uses two URL mappings:
@Controller
public class AdminController {
@RequestMapping("/v1/{userId}")
public SomeResponse showUserDetails(String userId) {
...
}
}
@Controller
public class UserController {
@RequestMapping("/v1/{userId}")
public SomeOtherResponse showUserStreamtring userId) {
...
}
}
In web.xml:
<servlet-mapping>
<servlet-name>public-api</servlet-name>
<url-pattern>/public</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>admin-api</servlet-name>
<url-pattern>/admin</url-pattern>
</servlet-mapping>



