web.xml中的context.xml与web.xml [英] context.xml vs web.xml in web application
问题描述
我正在开发一个小型Web应用程序。目标是使用Ajax +一个servlet创建一个welcome index.html
页面来处理ajax请求。
I am developing a small web application application. The objective is to create one welcome index.html
page with Ajax + one servlet to handle ajax requests.
虽然我以为我只能使用 web.xml
,我不想部署到 /
,但是到 / MyApp
。 NetBeans的项目属性提供了设置上下文路径的选项,这有助于我部署到 / MyApp
。但是,它会自动添加 /META-INF/context.xml
文件,这有点令人困惑。
Although I thought I would be fine with a web.xml
only, I don't want to deploy to /
, but to /MyApp
. NetBeans's project properties offers options to set a context path, which helps me deploying to /MyApp
. However, it automatically adds a /META-INF/context.xml
file, which is a bit confusing.
我的问题是:
1)我真的需要 context.xml
文件部署到 / MyApp
而不是 /
?
1) Do I really need a context.xml
file do deploy to /MyApp
instead of /
?
2)如果回答1)是不是,如何用 web.xml
完成相同的工作?
2) If answer to 1) is no, how to accomplish the same with web.xml
only?
3)究竟是什么 context.xml
到 web.xml
?
推荐答案
/META-INF/context.xml
是特定于Tomcat的配置文件。它用于配置应用程序部署到Tomcat的方式,包括其中存在的上下文路径等。其他容器具有类似的文件,可以包含在容器配置的WAR中。回答你的问题:
/META-INF/context.xml
is a Tomcat-specific config file. It's used to configure how your app is deployed to Tomcat, including, among other things, the context path at which it exists. Other containers have similar files that can be included in a WAR for container configuration. To answer your questions:
- 没有。嵌入式context.xml只是设置上下文路径的一种方式,正如我所指出的,它只能在Tomcat中工作。在Tomcat中,默认行为是将webapps部署到具有war文件名称的上下文,而不使用.war扩展名。
- 您无法在Web中设置上下文路径.XML。这是您的应用程序的部署描述符。它配置您的应用程序,并且上下文路径在您的应用程序外部。它属于您正在部署应用程序的服务器/容器。配置上下文路径总是在容器的配置中完成。
- 如果用config.xml,你的意思是context.xml,那么我想我已经回答了这个问题。如果没有,请澄清您的问题。
这篇关于web.xml中的context.xml与web.xml的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!