I am in the process of changing a project which used a simple java HTTPServer on port 8080 to that which uses the Spring MVC servlet framework.
There are lots of links in the application like so:
<a href=\"/rule\">Manage rules</a><br/>
Which worked fine using requests such as:
http://localhost:8080/send
However, these now don’t work unless I put the servlet name in front like so:
"<a href=\"/ServletName/rule\">Manage rules</a><br/>"
Just wondering is there any way around this, or is it a matter of just changing all the href links to add the servlet name in front of them?
Note that I dont have to add the servlet name in my @RequestMapping calls at the start of methods, its only links that are the problem. E.g. this works fine without adding the servlet name in front
@RequestMapping(value = "/send", method = RequestMethod.GET)
If you use JSPs in your view layer, use a tag library that has a link tag (or write one yourself). Basically, the link tag has to create the url by doing
The
<c:url>tag in JSTL does that, but it only generates the URL, not the link tag, but it can get you there like this: