开发者

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

开发者 https://www.devze.com 2023-02-17 17:35 出处:网络
I\'ve been trying to 开发者_Python百科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-hiberna

I've been trying to 开发者_Python百科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.


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>


If you rename your war as l.war and then place l.war inside Tomcat's webapp directory then you will be able to use http://mydomain.com/l/ to access your application.

0

精彩评论

暂无评论...
验证码 换一张
取 消