简体   繁体   English

JavaEE Web应用程序(Tomcat)和嵌套上下文路径

[英]JavaEE web apps (Tomcat) and nested context paths

Is it allowed to use nested context paths like: 是否可以使用嵌套的上下文路径,例如:

  • "/" for webapp X Webapp X的“ /”
  • "/y" for webapp Y? Web应用Y的“ / y”?

I have never used that layout before myself, but I need to help someone deploy an existing system, where this layout is used. 我从来没有使用过这种布局,但是我需要帮助某人部署使用该布局的现有系统。 It has actually worked so far, but suddenly , it doesn't anymore: 到目前为止,它实际上已经起作用了,但是突然之间 ,它不再起作用了:

  • Webapp X still works. Webapp X仍然有效。
  • The static pages for webapp Y still work - but the servlets from webapp Y don't work anymore. webapp Y的静态页面仍然有效-但是webapp Y的servlet不再起作用。

If we deploy webapp X under "/x" instead of "/", then both webapps work perfectly! 如果我们将Webapp X部署在“ / x”下而不是“ /”下,那么两个webapp都可以正常运行!

The first thing I wonder is: Is the above mentioned layout even allowed at all, or is this really a very shaky setup that depends on some amount of luck? 我想知道的第一件事是:是否甚至允许上述布局,或者这是否真的很不稳定,取决于运气? (Where would tomcat look, if I call www.example.com/y/someServlet ? I fear, that it might look in webappX's web.xml?) (如果我调用www.example.com/y/someServlet在哪里看?我担心,它可能会出现在webappX的web.xml中?)

The problem was caused by the fact, that webapp X was deployed twice: Once by the specified <context> element (which set the context path to "/"), and a second time by autoDeploy. 该问题是由于以下事实引起的:webapp X部署了两次:一次是通过指定的<context>元素(将上下文路径设置为“ /”),另一次是通过autoDeploy。

Moving webapp X out of the autodeploy (appBase) folder, into a different folder solved the problem. 将webapp X从autodeploy(appBase)文件夹移出到另一个文件夹解决了该问题。 See also http://tomcat.apache.org/tomcat-7.0-doc/config/context.html#Naming 另请参见http://tomcat.apache.org/tomcat-7.0-doc/config/context.html#Naming

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM