设置Tomcat默认上下文路径 [英] Set Tomcat Default Context Path

查看:166
本文介绍了设置Tomcat默认上下文路径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的 context.xml 文件中,我将以下内容设置为:< Context antiJARLocking =truepath =//>

In my context.xml file I set the following to: <Context antiJARLocking="true" path="/" />

当我从NetBeans运行我的项目时,它可以正常工作并转到 http:// localhost:8080 /登录。然后当我清洁&构建并进入Tomcat Manager并部署war文件,因为某些原因它会转到 http:// localhost:8080 / appName / login 。我不知道为什么它添加上下文路径或甚至从它获取它,但是当我手动部署它,这样做。当我直接从Netbeans运行项目时,它不会。在直接从NetBeans运行它之后,如果我去Tomcat管理器,那么它显示在上下文路径 / 中部署的应用程序是正确的。当我手动部署.war时,它会根据上下文路径 / appName

When I run my project from NetBeans then it works correctly and goes to http://localhost:8080/login. Then when I clean & build and go into Tomcat Manager and deploy the war file, for some reason it goes to http://localhost:8080/appName/login. I'm not sure why it's adding the context path or where it even gets it from but when ever I deploy it manually it does that. When ever I run the project directly from Netbeans then it doesn't. After I run it directly from NetBeans, if I go to Tomcat Manager then it shows the app deployed under context path / which is correct. When I deploy the .war manually then it deploys under context path /appName

推荐答案

听起来你正在将你的战争文件建立为appName.war。这就是tomcat在/ appName下部署它的原因。

It sounds like you are building your war file as "appName.war". That is the reason tomcat deploys it under "/appName".

如果您希望您的应用程序可访问/,您可以将war文件重命名为ROOT.war,并将其放在/ webapps中,并且可以在http:// localhost:8080 /

If you want your application accessible at /, you can rename your war file as ROOT.war and drop it in /webapps and it should be accessible at http : //localhost:8080/

这篇关于设置Tomcat默认上下文路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆