I'm mapping the url /modules/tips/SOME_ID/small
to access the tip with id SOME_ID and to render it using the view small.jsp
. The following code works great for this, however I am forced to repeat the string modules/tips
in two places. Spring MVC doesn't seem to have a convention for this that I can determine. Other than using a constant, is there a better way to reduce this repetition?
@Controller
public class TipsController{
@RequestMapping(value="/modules/tips/{tipId}/{viewName}",method=RequestMethod.GET)
public ModelAndView get(
@PathVariable String tipId,
@PathVariable String viewName) {
Tip tip = findTip(tipId);
return new ModelAndView("modules/tips/" + viewName,"tip",tip);
}
}