我可以在一个 Web 应用程序中有两个 web.xml 文件吗? [英] Can I have two web.xml files in a single web application?

查看:72
本文介绍了我可以在一个 Web 应用程序中有两个 web.xml 文件吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我可以拥有一个包含多个 web.xml 文件的应用程序吗?并且两个应用可以有父子关系,从而有两个web.xml吗?

Can i Have a single application with more than one web.xml files? And can two applications have a parent child relationship so that there are two web.xml?

推荐答案

servlet 3.0 以下不能.

For below servlet 3.0 you cannot.

如果您使用的是 3.0,则有 可能性.

If you are using 3.0 there is a possibility.

在 JSR 315:Java Servlet 3.0 规范中,引入了 web-fragment.xml 用于在 WEB-INF/lib 下打包的库 jar 的可插入性.web.xml 和 web-fragment.xml 的内容几乎相同.可以在那里定义 servlet、过滤器和侦听器.还可以在给定的 web-fragment.xml 中指定 metadata-complete=true.在后一种情况下,将跳过该 jar 中类的注释处理.使用 web-fragment.xml,库 jar 可以自包含并提供与 Web 相关的元数据信息.

In JSR 315: Java Servlet 3.0 Specification, web-fragment.xml is introduced for pluggability of library jars which are packaged under WEB-INF/lib. The content of web.xml and web-fragment.xml are almost the same. One can define servlets, filters and listeners there. One can also specify metadata-complete=true in a given web-fragment.xml. In the latter case, the annotation processing of classes in that jar would be skipped. With web-fragment.xml, library jars can be self-contained and provide web related metadata information.

当然,拥有两个 xml 会造成混乱,而且除此之外,如果您解释您的确切要求,您将获得解决问题的良好/标准解决方案.

For sure, having two xml creates confusion and besides all, If you explain whats your exact requirement, you'l get a good/standard solution for your problem.

这篇关于我可以在一个 Web 应用程序中有两个 web.xml 文件吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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