java, tomcat: what is the meaning of the id attribute in the tag web-app in web.xml?
What is the meaning of web.xml id attribute of the web-app tag?
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 rea开发者_如何学Pythonlly necessary? What is the value supposed to be?
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:
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.
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"/>
(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.)
AFAIK this is not needed (per the DTD as well). You can comment it out and see if that works, I am quite positive the app will load up just fine.
精彩评论