哪个Tomcat 5上下文文件优先? [英] Which Tomcat 5 context file takes precedence?

查看:202
本文介绍了哪个Tomcat 5上下文文件优先?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Tomcat文档说:

上下文描述符的位置是:

The locations for Context Descriptors are;

$ CATALINA_HOME / conf / [enginename] / [hostname] /context.xml

$ CATALINA_HOME / webapps / [webappname] /META-INF/context.xml

$CATALINA_HOME/conf/[enginename]/[hostname]/context.xml
$CATALINA_HOME/webapps/[webappname]/META-INF/context.xml

在我的服务器上,我有至少3个文件: / p>

On my server, I have at least 3 files floating around:

1 ...tomcat/conf/context.xml
2 ...tomcat/Catalina/localhost/myapp.xml
3 ...tomcat/webapps/myapp/META-INF/context.xml

优先顺序是什么?

推荐答案

对于您列出的文件,简单的回答假设您使用所有默认值,顺序是> conf / Catalina / localhost):

For the files you listed, the simple answer assuming you are using all the defaults, the order is (note the conf/Catalina/localhost):

...tomcat/conf/context.xml
...tomcat/conf/Catalina/localhost/myapp.xml
...tomcat/webapps/myapp/META-INF/context.xml

我将这个(以及下面的讨论)放在 Tomcat 5.5 上下文容器 的官方文档。

I'm basing this (and the following discussion) on the Tomcat 5.5 official documentation for the Context Container.

所以,如果这是简单的答案,那么完整的答案是什么?

So if that's the simple answer, whats the complete answer?

Tomcat 5.5。将会在除了你列出的那些元素之外的其他地方查找< Context> 元素。

Tomcat 5.5. will look in a couple of other places for <Context> elements beyond those you've listed (see the official docs).

如果Tomcat发现一个 Catalina / localhost / myapp.xml META-INF / context.xml c $ c>。因此,如果你实际上有所有的文件,它更正确的说 META-INF / context.xml 不相关,而不是

The META-INF/context.xml will never be opened if Tomcat finds a Catalina/localhost/myapp.xml. So if you actually have all the files above, its more correct to say the the META-INF/context.xml is irrelevant, not that it's the lowest precedence.

如果在您的网站中说出< Context override =true...> Catalina / localhost / myapp.xml 将使其成为最高优先级,而不管 conf / context.xml 。你的 META-INF \context.xml 中也有同样的事情,只要你没有 Catalina / localhost / myapp.xml (见上一段)。

If you say <Context override="true" ...> in your Catalina/localhost/myapp.xml that will make it the highest precedence, regardless of conf/context.xml. Same thing in your META-INF\context.xml, as long as you don't have a Catalina/localhost/myapp.xml (see previous paragraph).

此外, / Catalina / localhost / 路径在实际上来自默认 conf / server.xml 并匹配< Engine name =CatalinadefaultHost = localhost> 。如果您的 server.xml 使用不同的值 name defaultHost < Engine> 中,这是Tomcat看起来的dir结构。

Also, the /Catalina/localhost/ portion of the path in the files above actually comes out of the "default" conf/server.xml and matches the <Engine name="Catalina" defaultHost="localhost">. If your server.xml uses different values for name and defaultHost in the <Engine>, that's the dir structure where Tomcat will look.

code> ... tomcat \ 部分文件,Tomcat使用 $ CATALINA_BASE 环境变量中的dir。如果没有设置,那么它使用来自 $ CATALINA_HOME 环境变量的dir,这是Tomcat安装的目录。我喜欢设置和使用 $ CATALINA_BASE ,这样我就不会污染我的Tomcat安装。

Finally, for the ...tomcat\ portion of the files you listed, Tomcat uses the dir from the $CATALINA_BASE environment variable. If that's not set, then it uses the dir from the $CATALINA_HOME environment variable, which is the directory of the Tomcat installation. I like to set and use $CATALINA_BASE so that I don't "pollute" my Tomcat installation.

这篇关于哪个Tomcat 5上下文文件优先?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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