I am coming from a ASP.Net MVC world where Microsoft provides the LinkExtensions.ActionLink method in Razor (their version of JSP) to generate anchor element (a element) to a specific controller/action.
The concept is pretty simple: the Razor (JSP) code references the controller and action, the ActionLink function does the hard work of generating the correct URI to get to that controller/action.
Is there anything like this in Spring MVC?
Unfortunately, Spring doesn’t support this at the moment, although there is a feature request for it. The best you can do right know is use
<spring:url>and hardcode the path to the controller and action.<spring:url>will give you a context-root-relative URL.Part of the difficulty in implementing this is that Spring gives you the power to arbitrarily define your mappings (i.e. with
@RequestMapping). So if you’re not usingControllerClassNameHandlerMappingit can be an issue.