tomcat 6:访问Web应用程序时URL中没有战争名称并且不覆盖ROOT?
在我的战争的 META-INF/context.xml 中,我有:
<?xml version="1.0" encoding="UTF-8"?>
<Context path="/foobar" docBase="my-long-war-name"/>
我将战争部署到 webapps/ 目录,并确认我的 contex.xml 位于 %CATALINA_HOME%\conf\Catalina\ localhost 名称为 my-long-war-name.xml
现在,不再通过 http://localhost:8080/my-long-war- 访问我的 REST 服务name/contacts/data
tomcat 应该允许 http://localhost:8080/foobar/contacts/data
但我只能通过以前的 URL 访问我的服务。就好像它完全忽略了上面为我的网络应用程序给出的路径。我什至尝试省略 docBase ,但这也不起作用。
为什么这不起作用?它应该是这么基本!
in my war's META-INF/context.xml
I have:
<?xml version="1.0" encoding="UTF-8"?>
<Context path="/foobar" docBase="my-long-war-name"/>
I deploy my war to the webapps/ directory and I confirm that my contex.xml is in %CATALINA_HOME%\conf\Catalina\localhost
with the name my-long-war-name.xml
Now, instead of accessing my REST service through http:/ /localhost:8080/my-long-war-name/contacts/data
tomcat should allow http:/ /localhost:8080/foobar/contacts/data
but I can only access my service through the former URL. It's as if it completely ignores the path given above for my web app. I even tried omitting docBase
and that didn't work either.
why doesn't this work?! it's supposed to be so basic!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我不明白为什么你需要
。部署到 Tomcat 时我从来没有碰过这一点,一切都工作正常。为什么不将 WAR 命名为 foobar,部署它,然后就完成它呢?你似乎执着于这个想法,尽管有相反的证据表明它是多么基本。
I don't see why you need the
<Context>
. I never touch that when deploying to Tomcat, and everything works fine.Why don't you just make the WAR name foobar, deploy it, and be done with it? You seem to be wedded to this idea in spite of the evidence to the contrary about how basic it is.