Tomcat context.xml 文件,有层次吗? [英] Tomcat context.xml files, is there a hierarchy?
问题描述
我正在尝试在我在 Tomcat5 上运行的应用程序之一中使用符号链接.感谢另一个StackOverflow问题的帮助,我能够做到通过在
I am trying to use symbolic links in one of the applications I have running on Tomcat5. Thanks to some help from another StackOverflow question I was able to do it by creating a context.xml file in
/...myapplication/META-INF/context.xml
/...myapplication/META-INF/context.xml
我现在正在尝试在生产服务器上实现这一点.但是,还有其他应用程序在其上运行.还有另一个上下文文件
I am now trying to implement this on a production server. However, there are other applications running on it. And there is another context file
/...tomcat/conf/context.xml
/...tomcat/conf/context.xml
在我看来,这些是在服务器范围内为所有应用程序设置配置.如果我在 conf/context.xml 文件中允许链接,我的符号链接就起作用了.如果我不允许 conf/context.xml 中的链接,即使我在 META-INF/context.xml 中允许它们,我的应用程序的符号链接也不起作用
It seems to me these are setting configurations server-wide to all applications. If I allowLinks in the conf/context.xml file, my symbolic links work. If I don't allowLinks in conf/context.xml, my application's symbolic links do not work, even though I have allowed them in the META-INF/context.xml
我的问题是,conf/context.xml 控制所有应用程序吗?如果我希望符号链接仅在一个应用程序中工作,是否需要删除 conf/context.xml 并为每个应用程序创建新的上下文文件?或者有没有办法只允许我的应用程序中的符号链接?
My question is, does the conf/context.xml control all applications? If I want symbolic links to work only in one application, do I need to remove the conf/context.xml and create new context files for each application? Or is there a way I can allow symbolic links in myapplication only?
推荐答案
参见 我的回答 对哪个 Tomcat 5 上下文文件优先"问题.
关于您的特定 allowLinks
问题,conf/context.xml
中的值默认优先.如果你在 conf/context.xml
中什么也没说,默认值是 allowLinks="false"
在您的 conf/context.xml
中.
Regarding your specific allowLinks
question, the value in conf/context.xml
takes precedence by default. If you say nothing in your conf/context.xml
, the default value is allowLinks="false"
in your conf/context.xml
.
如果您只想为您的 myapplication
更改它,请尝试在您的 META 中说
将不起作用,因为通常 <Context allowLinks="true" ...>
-INF/context.xmlconf/context.xml
设置将优先.
If you want to change it only for your myapplication
, trying to say <Context allowLinks="true" ...>
in your META-INF/context.xml
will have no effect because normally the conf/context.xml
setting will take precedence.
但是,如果您在 META-INF/context 中说
,那么您在 <Context allowLinks="true" override="true" ...>
.xmlMETA-INF/context.xml
中的所有
设置将是最高优先级,覆盖任何内容在 conf/context.xml
.
But, if you say <Context allowLinks="true" override="true" ...>
in your META-INF/context.xml
, then all your <Context>
settings in META-INF/context.xml
will be highest precedence, overriding anything in conf/context.xml
.
最后,我建议使用 conf/Catalina/localhost/myapplication.xml
文件而不是 myapplication/WEB-INF/context.xml
文件.这种技术意味着您可以保持 WEB-INF 的内容干净,这是您的 web 应用程序的内脏——我不喜欢冒险在我的 web 应用程序内脏.:-)
Finally, instead of a myapplication/WEB-INF/context.xml
file, I recommend using a conf/Catalina/localhost/myapplication.xml
file. This technique means you can keep the contents of your WEB-INF clean, which is the guts of your webapp -- I don't like to risk mucking about in the guts of my webapp. :-)
这篇关于Tomcat context.xml 文件,有层次吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!