Separating war application name from war file name

后端 未结 7 2319
一个人的身影
一个人的身影 2020-12-05 06:50

Currently if i deploy a war file on tomcat named say myapp.war, I can access its url by http://localhost/myapp/MyServlet.

However what I want is to depl

7条回答
  •  悲哀的现实
    2020-12-05 07:32

    The solution is to stop using the automatic deployment feature of Tomcat, which takes the shortcut of setting the "context name" (the /myapp part of the URL) to the portion of the WAR filename before ".war".

    Instead, extract the WAR contents to the filesystem yourself and setup an XML file at TOMCAT_HOME/conf/[enginename]/[hostname]/[contextname].xml which points the desired context path (such as /myapp) to the location of the application on disk (such as /opt/webapps/myapp-1.1.0/).

    The Tomcat reference docs provide a good explanation of how Tomcat deploys applications automatically, and how you can configure customized logic for the mapping of context path to application file location (there are a handful of alternate ways to set this up other than the one I suggest above).

提交回复
热议问题