I am writing a web application using Spring MVC. I am using annotations for the controllers, etc. Everything is working fine, except when it comes to actual links in the app
Since it's been some years I thought I'd chip in for others looking for this. If you are using annotations and have a controller action like this for instance:
@RequestMapping("/new") //<--- relative url
public ModelAndView newConsultant() {
ModelAndView mv = new ModelAndView("new_consultant");
try {
List list = ConsultantDAO.getConsultants();
mv.addObject("consultants", list);
} catch (Exception e) {
e.printStackTrace();
}
return mv;
}
in your .jsp (view) you add this directive
<%@taglib uri="http://www.springframework.org/tags" prefix="spring"%>
and simply use
New consultant
where
value's value should match @RequestMapping's argument in the controller action and
var's value is the name of the variable you use for href
HIH