问题
我有我的应用程序的war文件。我需要在根级别部署它。当前网址是http://localhost:8080/war_name/application_name
。
#1 热门回答(181 赞)
你有几个选择:
- 从tomcat中删除开箱即用的ROOT /目录,并在部署之前将war文件重命名为ROOT.war。
- 部署你的战争(来自你的例子)war_name.war并配置conf / server.xml中的上下文根以使用war文件:<Context path =""docBase ="war_name"debug ="0"reloadable ="true "> </上下文>
第一个更容易,但更多的kludgy。第二个可能是更优雅的方式。
#2 热门回答(30 赞)
在tomcat v.7(香草安装)
在你的conf / server.xml中,在文件末尾添加以下位,就在</Host>
closing标记之前:
<Context path="" docBase="app_name">
<!-- Default set of monitored resources -->
<WatchedResource>WEB-INF/web.xml</WatchedResource>
</Context>
注意docBase属性。这是重要的一点。你可以确保在更改根Web应用程序之前部署了app_name,或者只是将解压缩的webapp(app_name)复制到tomcat的webapps文件夹中。启动,访问root,在那里看到你的app_name!
#3 热门回答(11 赞)
在具有这些更改的tomcat 7中,我可以在/ ROOT处的/和ROOT访问myAPP
<Context path="" docBase="myAPP">
<!-- Default set of monitored resources -->
<WatchedResource>WEB-INF/web.xml</WatchedResource>
</Context>
<Context path="ROOT" docBase="ROOT">
<!-- Default set of monitored resources -->
<WatchedResource>WEB-INF/web.xml</WatchedResource>
</Context>
将上面的内容添加到server.xml中的<Host>
部分