首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > Web前端 >

web.xml调度描述文件定义

2012-09-05 
web.xml部署描述文件定义Servlet 2.3之前的版本使用DTD作为部署描述文件的定义,其web.xml的格式为如下所示

web.xml部署描述文件定义


Servlet 2.3之前的版本使用DTD作为部署描述文件的定义,其web.xml的格式为如下所示:

?

  <?xml version="1.0" encoding="IS0-8859-1"?>  <!DOCTYPE web-app  PUBLIC "-//sunMicrosystems,Inc.//DTD WebApplication 2.3f//EN"  "http://java.sun.com/j2ee/dtds/web-app_2.3.dtd">  <web-app>  .......  </web-app>
?

?

Servlet 2.4版首次使用XML Schema定义作为部署描述文件,这样Web容器更容易校验web.xml语法。同时XML Schema提供了更好的扩充性,其web.xml中的格式如下所示:

?

  <?xml version="1.0" encoding="UTF-8"?>  <web-app version="2.4" xmlns=http://java.sun.com/xml/ns/j2ee  xmlns:workflow=http://www.workflow.com  xmins:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee  http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">  .........  </web-app>

?

?

XML Schema Definition: tomcat6.0\lib\servlet-api.jar?javax\servlet\resources\web-app_2_4.xsd

部分说明:

    <xsd:annotation>    <xsd:documentation>      <![CDATA[This is the XML Schema for the Servlet 2.4 deployment descriptor.The deployment descriptor must be named "WEB-INF/web.xml" in theweb application's war file.  All Servlet deployment descriptorsmust indicate the web application schema by using the J2EEnamespace:http://java.sun.com/xml/ns/j2eeand by indicating the version of the schema byusing the version element as shown below:    <web-app xmlns="http://java.sun.com/xml/ns/j2ee"      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"      xsi:schemaLocation="..."      version="2.4">      ...    </web-app>The instance documents may indicate the published version ofthe schema using the xsi:schemaLocation attribute for J2EEnamespace with the following location:http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd]]>    </xsd:documentation>  </xsd:annotation>
???

?

最新的Servlet 2.5版XML Schema web.xml中的格式:

    <web-app xmlns="http://java.sun.com/xml/ns/javaee"       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"       xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee  http://java.sun.com/xml/ns/j2ee/web-app_2_5.xsd"       version="2.5">       ...     </web-app> 
?

热点排行