Search code examples
javaspringurltomcatcontextpath

Spring, Tomcat trying to set Context URL path in server.xml and it's not working


I've been trying to figure out how to do this and as far as I can tell I am doing what the various resources I have found say to do. I have a Spring application called spring-hibernate-mysql that I want to be able to access at the path: http://example.com/l/ rather than the way I currently have to at: http://example.com/spring-hibernate-mysql/l/.

My app name as it appears in eclipse is spring-hibernate-mysql and when I build it the war is called spring-hibernate-mysql.war

I have placed this code in my Tomcat's server.xml but it is not working: <Context docBase="spring-hibernate-mysql" path="" reloadable="true" />

Any advice is appreciated.


Solution

  • You have to setup this in your web.xml in filter mappings.

    e.g.:

    <filter-mapping>
        <filter-name>myapp</filter-name>
        <url-pattern>/l/*</url-pattern>
    </filter-mapping>