Can I have two web.xml files in a single web application?(我可以在一个 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 文件吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:我可以在一个 Web 应用程序中有两个 web.xml 文件吗?


基础教程推荐
- 在 Java 中创建日期的正确方法是什么? 2022-01-01
- 如何在 JFrame 中覆盖 windowsClosing 事件 2022-01-01
- 从 python 访问 JVM 2022-01-01
- Java Swing计时器未清除 2022-01-01
- 大摇大摆的枚举 2022-01-01
- 验证是否调用了所有 getter 方法 2022-01-01
- Java 实例变量在两个语句中声明和初始化 2022-01-01
- 多个组件的复杂布局 2022-01-01
- 如何在 Spring @Value 注解中正确指定默认值? 2022-01-01
- 不推荐使用 Api 注释的描述 2022-01-01