I am learning Spring 3 and I use it in a simple web application.
Now I am implementing Spring MVC controller using annotations, and I am wondering: Is there any best practice using @RequestMapping annotation?
I mean: I saw that usually the URL displayed in this annotation is hard-coded in the class ...
Is there a way to pass the url in a โloosely coupled wayโ (to get a more reusable class)?
I know that there are some wild cards that can be used, but I think this is not a solution ... Am I wrong?
EDIT:
I am adding an example to better explain my doubts.
Suppose I want my controller to be called by a request to /foo/bar/baz/mypage.htm , in my controller the handler method will be annotated using @RequestMapping("/foo/bar/baz/mypage") .
Now I decided to change the URL that starts my controller to /foo/bar/otherpage.htm , so I need to edit my class, put @RequestMapping("/foo/bar/otherpage") in my handler method, recompile the project and deploy it again.
It seems to me that this is not so practical ...
source share