How to hide spring mvc web app name in the browser url?

生来就可爱ヽ(ⅴ<●) 提交于 2020-01-05 04:02:23

问题


I have a spring mvc 3.x web app in eclipse where the resource project artifact name is "webapp". So, http://localhost:8080/webapp will load the main home page using tomcat 7 with the eclipse IDE.

However, when I release to tomcat 7.0 to some prod servers I don't want the URL to resolve to http://mywebsite.com/webapp but instead http://mywebsite.com

How can I achieve this?


回答1:


You can follow either of below approaches

  1. Delete existing ROOT/ directory (in webapps) from tomcat and rename your war file to ROOT.war and then deploy it.

  2. Configure the context root in tomcat's conf/server.xml to use your war file (assuming my_war is your war name)

    < Context path="" docBase="my_war" reloadable="true">



来源:https://stackoverflow.com/questions/18072190/how-to-hide-spring-mvc-web-app-name-in-the-browser-url

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!