I am developing a RESTful service using Spring 3.0 running on Tomcat Apache 6.0 environment. The Spring DispatcherServlet is configured at "/spring/*". The Spring servlet handles multiple clients and has many Controllers in the application. I am adding a new Controller for the REST service. I want all of my controller classes to have a identification prefix like "ws" (web-service) so that the complete URL to a resource looks like this:
http://<server>:<port>/<context>/spring/ws/service1
The only way I found with Spring annotation is to use @RequestMapping like this:
@Controller
@RequestMapping("/ws/service1")
public class Service1 {
@RequestMapping(method=RequestMethod.GET)
@ResponseBody
public String getHtml() { ... }
....
}
But since I have dozens of classes, I don't want to put "/ws" prefix in each class. So that if another developer adds a new service, he does not have to remember to put this prefix and also if we decide to change the prefix name from "/ws" to something else, I don't have to change all the files. I found that @RequestMapping annotation is only applicable to Methods or Classes and not at the package level.
Is there any way I can configure that all my REST Controllers are accessed with the prefix?
Please note that I can not change the web.xml URL mapping of Spring servlet since, there are other Controllers which are running with that URL.