I have a Java application running on Tomcat 7. I want my application to have it's name in the URL. For example:
http://localhost:8080/MyApp
I build the WAR, deploy, and the application is accessed correctly. However, all of my <a>
and <form>
tags don't add the application name to the URLs. That is, doing something like:
<a href="/myPage">Click Me</a>
does not work. The link ends up like this:
http://localhost:8080/myPage
instead of
http://localhost:8080/MyApp/myPage
Is there any way to configure Tomcat to add the application name onto links, etc? As mentioned, I don't want strip the application name off of the URL (i.e. making it the root). I know there are some work arounds (like manually adding the context path onto the URL, using <c:url>
, etc. But I am wondering if Tomcat can be told to do this. I figure this is the place to ask, since the request isn't getting to my application. If it matters, I am using Spring MVC and Maven.