Tomcat context.xml 文件,有层次结构吗?

发布于 2024-07-09 13:28:16 字数 649 浏览 7 评论 0 原文

我正在尝试在 Tomcat5 上运行的应用程序之一中使用符号链接。 感谢另一个 StackOverflow 问题的帮助,我能够做到这一点 中创建 context.xml 文件,

通过在/...myapplication/META-INF/context.xml

我现在尝试在生产服务器上实现此功能。 但是,还有其他应用程序在其上运行。 还有另一个上下文文件

/...tomcat/conf/context.xml

在我看来,这些是在服务器范围内向所有应用程序设置配置。 如果我在 conf/context.xml 文件中允许链接,我的符号链接就会起作用。 如果我不允许conf/context.xml中的链接,我的应用程序的符号链接将不起作用,即使我已在META-INF/context.xml中允许它们

我的问题是,conf/context.xml是否控制所有应用程序? 如果我希望符号链接仅在一个应用程序中工作,是否需要删除 conf/context.xml 并为每个应用程序创建新的上下文文件? 或者有没有办法只允许在我的应用程序中使用符号链接?

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

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

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

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

时光瘦了 2024-07-16 13:28:16

请参阅我对“哪个 Tomcat 5 上下文文件优先”问题。

关于您的特定 allowLinks 问题,默认情况下,conf/context.xml 中的值优先。 如果您在 conf/context.xml 中未指定任何内容,则默认值为 allowLinks="false" 在您的 conf/context.xml 中。

如果您只想为您的 myapplication 更改它,请尝试在 META-INF/ 中说 context.xml 将不起作用,因为通常 conf/context.xml 设置将优先。

但是,如果您说 override="true" ...> 在您的 META-INF/context.xml 中,然后您的所有 设置在 META-INF/context.xml 中> 将具有最高优先级,覆盖 conf/context.xml 中的任何内容。

最后,我建议使用 conf/Catalina/localhost/myapplication.xml 文件,而不是 myapplication/WEB-INF/context.xml 文件。 这种技术意味着你可以保持 WEB-INF 的内容干净,这是你的 web 应用程序的核心——我不想冒险破坏我的 web 应用程序的核心。 :-)

See my answer to the "Which Tomcat 5 context file takes precedence" question.

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.

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.

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.

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. :-)

浅听莫相离 2024-07-16 13:28:16

只是补充一点。

通常,meta-inf/context.xml 会被复制到conf/Catalina/localhost/myapplication.xml

当重新部署一个war 文件时,conf/Catalina/localhost/myapplication.xml 会被删除,并按照上面的描述复制一个新的。

这可能是一个真正的痛苦。 我喜欢应用程序特定上下文的想法,但我不明白将其放在 meta-inf 目录中有何帮助。

对于 Prod、UAT 等来说,这真的很痛苦。

因此,对于任何服务器静态但特定于应用程序的内容,最好将其放在 conf/context.xml 中。 其缺点是它保存了多个应用程序的上下文,触摸其中一个您就会无意中触摸所有应用程序。

Just to add a point.

Usually th meta-inf/context.xml is copied to the conf/Catalina/localhost/myapplication.xml

When redploying a war file the conf/Catalina/localhost/myapplication.xml is deleted and a new one copied in as described above.

This can be a real pain. I like the idea of application specific context but I fail to see how having this in the meta-inf directory helps.

For Prod, UAT, etc this becomes a real pain.

So for anything server static but application specific it is better to put it in the conf/context.xml. Which has the negative that it holds context for several applications, touch one you inadvertently touch them all.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文