简体   繁体   中英

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.

如果您将战争重命名为l.war,然后将l.war放入Tomcat的webapp目录中,那么您将能够使用http://mydomain.com/l/访问您的应用程序。

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

eg:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM