I am using Spring MVC with JSPs. My project is still undergoing many changes, so request mappings are changed often. However, when a request mapping is changed, we end up with broken links if we don't find and update every JSP that has a link to the changed request mapping.

Here's an example:

controller:
Code:
@Controller @RequestMapping("/login")
public class LoginController {

    @RequestMapping(method=GET)
    public String getMainLoginPage() {...}

    @RequestMapping(value="/{domain}", method=GET)
    public String getDomainLoginPage(@PathVariable("domain") String domain) {...}

    @RequestMapping(method=POST)
    public String login(@Valid LoginForm form) {...}

}
JSP:
Code:
<a href="${pageContext.request.contextPath}/login">General Login Page</a>
<a href="${pageContext.request.contextPath}/login/whatever">Whatever Domain Login Page</a>
Let's say, from the example above, we changed the request mapping for getDomainLoginPage() to "/login/to/{domain}". What can be built or modified to have this change automatically reflected in the JSP?

I have an idea on how to do this, but I'm hoping there's a less manual way of doing this with Spring MVC. Here's my idea:

1. Define all request mapping paths as static final Strings. Use the constant Strings in the Controller @RequestMapping annotations.

2. Create a static method for every request mapping. The method uses the corresponding static final String from point 1. The method signatures allow values for path variables and query params to be passed in. The methods return the generated URI string.

3. Create a taglib around the static methods and use the String. Use the taglib from the JSP to build URIs.

The problem with my idea is that it requires manual maintenance of the static methods and taglib. Perhaps there should be a way to name each request mapping, via a "name" parameter in the @RequestMapping annotation. Then some functionality can be built around allowing JSPs to reference a request mapping by name rather than having to hard-code the path.

What are your thoughts/opinions on this?