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

查看:517
本文介绍了我可以在一个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天全站免登陆