Servlet 2.3 deployment descriptor

注:web.xml中提示错误The content of element type "web-app" must match

该错误的原因是元素排放顺序有误,解决其实也很简单,按照上面的描述将各元素排序即可

 <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE web-app PUBLIC
"-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd" >
<web-app>
<icon></icon>
<display-name></display-name>
<description></description>
<distributable />
<context-param>
<param-name></param-name>
<param-value></param-value>
</context-param>
<filter>
<filter-name></filter-name>
<filter-class></filter-class>
<init-param>
<param-name></param-name>
<param-value></param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name></filter-name>
<url-pattern></url-pattern>
</filter-mapping>
<listener>
<listener-class></listener-class>
</listener>
<servlet>
<servlet-name></servlet-name>
<servlet-class></servlet-class>
<init-param>
<param-name></param-name>
<param-value></param-value>
</init-param>
</servlet>
<servlet-mapping>
<servlet-name></servlet-name>
<url-pattern></url-pattern>
</servlet-mapping>
<session-config></session-config>
<mime-mapping>
<extension></extension>
<mime-type></mime-type>
</mime-mapping>
<welcome-file-list>
<welcome-file></welcome-file>
</welcome-file-list>
<error-page>
<error-code></error-code>
<location></location>
</error-page>
<taglib>
<taglib-uri></taglib-uri>
<taglib-location></taglib-location>
</taglib>
<resource-env-ref>
<description></description>
<resource-env-ref-name></resource-env-ref-name>
<resource-env-ref-type></resource-env-ref-type>
</resource-env-ref>
<resource-ref>
<description></description>
<res-ref-name></res-ref-name>
<res-type></res-type>
<res-auth></res-auth>
<res-sharing-scope></res-sharing-scope>
</resource-ref>
<security-constraint>
<display-name></display-name>
<web-resource-collection>
<web-resource-name></web-resource-name>
<description></description>
</web-resource-collection>
</security-constraint>
<login-config></login-config>
<security-role>
<description></description>
<role-name></role-name>
</security-role>
<env-entry>
<description></description>
<env-entry-name></env-entry-name>
<env-entry-value></env-entry-value>
<env-entry-type></env-entry-type>
</env-entry>
<ejb-ref>
<description></description>
<ejb-ref-name></ejb-ref-name>
<ejb-ref-type></ejb-ref-type>
<home></home>
<remote></remote>
<ejb-link></ejb-link>
</ejb-ref>
<ejb-ref>
<description></description>
<ejb-ref-name></ejb-ref-name>
<ejb-ref-type></ejb-ref-type>
<home></home>
<remote></remote>
<ejb-link></ejb-link>
</ejb-ref>
</web-app>

Servlet 2.4 deployment descriptor

J2EE 1.4 XML schema, namespace is http://java.sun.com/xml/ns/j2ee

<web-app xmlns="http://java.sun.com/xml/ns/j2ee"
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_4.xsd"
version="2.4"> <display-name>Servlet 2.4 Web Application</display-name>
</web-app>

Servlet 2.5 deployment descriptor

Java EE 5 XML schema, namespace is http://java.sun.com/xml/ns/javaee

<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/javaee
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
version="2.5">
</web-app>

Servlet 3.0 deployment descriptor

Java EE 6 XML schema, namespace is http://java.sun.com/xml/ns/javaee

<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/javaee
http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
version="3.0">
</web-app>

Servlet 3.1 deployment descriptor

Java EE 7 XML schema, namespace is http://xmlns.jcp.org/xml/ns/javaee/

<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee
http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
version="3.1">
</web-app>

仅做笔记!

参考文档地址:http://www.mkyong.com/web-development/the-web-xml-deployment-descriptor-examples/

web.xml文件模板的更多相关文章

  1. web.xml文件:

    在web.xml配置文件是一个的J2EE配置文件,决定如何处理HTTP请求servlet容器的元素.它不是严格意义上的Struts2的配置文件,但它是一个文件,需要配置Struts2的工作. 正如前面 ...

  2. web.xml文件加载顺序

    1.启动一个WEB项目的时候,WEB容器会去读取它的配置文件web.xml,读取<listener>和<context-param>两个结点. 2.紧急着,容创建一个Servl ...

  3. Java Web的web.xml文件作用及基本配置(转)

    其实web.xml就是asp.net的web.config一个道理. 说明: 一个web中完全可以没有web.xml文件,也就是说,web.xml文件并不是web工程必须的. web.xml文件是用来 ...

  4. web.xml文件详解

      web.xml文件详解 Table of Contents 1 listener. filter.servlet 加载顺序 2 web.xml文件详解 3 相应元素配置 1 listener. f ...

  5. web.xml 文件配置01

    web.xml 文件配置01   前言:一般的web工程中都会用到web.xml,方便开发web工程.web.xml主要用来配置Filter.Listener.Servlet等.但是要说明的是web. ...

  6. web.xml文件中的web-app元素 部署

    [转载]web.xml文件中的web-app元素 (2012-05-24 13:35:57) 转载▼ 标签: 转载 分类: java 挺全 的 呵呵呵 转了 原文地址:web.xml文件中的web-a ...

  7. WEB项目web.xml文件中classpath: 跟classpath*:使用的区别

    引用一篇很不错的文章:http://blog.csdn.net/wxwzy738/article/details/16983935 首先 classpath是指 WEB-INF文件夹下的classes ...

  8. web.xml文件中加载顺序的优先级

    在项目中总会遇到一些关于加载的优先级问题,近期也同样遇到过类似的,所以自己查找资料总结了下,下面有些是转载其他人的,毕竟人家写的不错,自己也就不重复造轮子了,只是略加点了自己的修饰. 首先可以肯定的是 ...

  9. web.xml文件的作用

    每个javaEE工程中都有web.xml文件,那么它的作用是什么呢?它是每个web.xml工程都必须的吗? 一个web中可以没有web.xml文件,也就是说,web.xml文件并不是web工程必须的. ...

随机推荐

  1. js正则匹配两位小数

    今天写一个用js正则校验最多保留两位小数的格式. a = /^\d+|\d+\.\d{1,2}$/; 测试 a.test(1.222); 结果:true 一下蒙了,怎么可能,最后找了好久,原来需要把^ ...

  2. BIOS/MBR UEFI/GPT关系与区别-资料整理

    ---恢复内容开始--- 关于 BIOS/MBR UEFI/GPT他们之间的关系一直比较疑惑, 首先一点前提 BIOS UEFI 是一类,是控制硬件,引导启动的:MBR GPT是硬盘的分区定义.. 后 ...

  3. composer安装教程 windows系统 | Linux系统 | mac系统

    如何安装 Composer 下载 Composer 安装前请务必确保已经正确安装了 PHP.打开命令行窗口并执行 php -v 查看是否正确输出版本号. 打开命令行并依次执行下列命令安装最新版本的 C ...

  4. jQuery loop over JSON字符串 – $.each实例

    先来一段简单的javascript对象的遍历: var json = [ {"id":"1","tagName":"apple&q ...

  5. [小问题笔记(八)] 常用SQL(读字段名,改字段名,打印影响行数,添加默认值,查找存储过程等)

    读取所有字段,自然排序 declare @fields varchar(max) Select @fields=ISNULL(@fields,'')++name+',' from syscolumns ...

  6. [小问题笔记(七)] JS和 jQuery常用语句笔记(隐藏/显示/禁用标签 日期操作 跳转等)

    隐藏/显示标签 $("#div1").css("display", "none");$("#div2").css(&qu ...

  7. spring 及 spring boot 资源文件配置

    Spring配置文件引入xml文件: <import resource=" " />标签使用总结 https://www.cnblogs.com/javahr/p/83 ...

  8. python正则表达式 Python Re模块

    最近在学python 练习的时候随手写的,方便以后自己参考~如果能对其他同学有所帮助就再好不过了 希望大家指正哦~  我会随时整理的,先这样~ 正则表达式 1.元字符([ ]),它用来指定一个char ...

  9. 在ajax请求下的缓存机制

    1.在服务端加 header(“Cache-Control: no-cache, must-revalidate”);2.在ajax发送请求前加上 anyAjaxObj.setRequestHeade ...

  10. servlet初始化参数

    使用<context-param>标签初始化的参数是被应用程序中所有的servlet所共享.但是有时候我们需要为某一个特定的servlet配置参数,这个时候我们就需要使用servlet初始 ...