java、tomcat:web.xml中标签web-app中的id属性是什么意思? [英] java, tomcat: what is the meaning of the id attribute in the tag web-app in web.xml?

查看:36
本文介绍了java、tomcat:web.xml中标签web-app中的id属性是什么意思?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

web-app 标签的 web.xml id 属性是什么意思?

What is the meaning of web.xml id attribute of the web-app tag?

Eclipse 将其生成为 id="WebApp_ID".我使用的是 Servlet 规范 2.5 版,根据 此答案 不包含该 ID.

Eclipse generated it as id="WebApp_ID". I was using version the Servlet specification version 2.5, I switched to using 3.0, with the suggestion of this answer that doesn't include that id.

真的有必要吗?价值应该是多少?

Is it really necessary? What is the value supposed to be?

推荐答案

较新版本的 servlet 规范使用 .xsd 文件,但没有关于 id 属性的更多信息,但如果您回到带有 .dtd 的旧版本,比如web_app_2_2.dtd,你发现:

The newer versions of the servlet spec use .xsd files with no further information on the id attribute, but if you go back to the older versions with .dtd, such as web_app_2_2.dtd, you find:

ID 机制是为了让工具能够轻松制作特定于工具的参考到部署的元素描述符.这允许工具产生额外的部署信息(即超出标准部署描述符信息)来存储非标准单独文件中的信息,以及轻松参考这些特定于工具的文件中的信息标准网络应用部署描述符.

The ID mechanism is to allow tools to easily make tool-specific references to the elements of the deployment descriptor. This allows tools that produce additional deployment information (i.e information beyond the standard deployment descriptor information) to store the non-standard information in a separate file, and easily refer from these tools-specific files to the information in the standard web-app deployment descriptor.

例如,WebSphere Application Server 在其旧的 bnd 和 ext 文件中使用了 id 机制:

For example, WebSphere Application Server used the id mechanism in its old bnd and ext files:

web.xml:
<web-app id="WebApp_ID" ...

ibm-web-app-bnd.xmi:
<webappbnd:WebAppBinding ...
  <webapp href="WEB-INF/web.xml#WebApp_ID"/>

(谢天谢地,对于 ibm-web-bnd/ext 的较新 .xml 文件格式,不再需要使用 id 属性对工具友好,但开发人员讨厌使用 id 属性,但我离题了.)

(Thankfully, this is tool-friendly-but-developer-annoying use of id attributes is no longer necessary with the newer .xml file format for ibm-web-bnd/ext, but I digress.)

这篇关于java、tomcat:web.xml中标签web-app中的id属性是什么意思?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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