Java Servlet 2.3/2.4/2.5/3.0/3.1/4.0 各web.xml文件
Posted ylft
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Java Servlet 2.3/2.4/2.5/3.0/3.1/4.0 各web.xml文件相关的知识,希望对你有一定的参考价值。
1. Servlet 4.0(Tomcat 9.x)
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="4.0" 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_4_0.xsd">
<display-name>Web Application</display-name>
</web-app>
2. Servlet 3.1(Tomcat 8.x)
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="3.1" 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"
metadata-complete="true">
<display-name>Web Application</display-name>
</web-app>
//当出现不能识别注解表示的servlet时,删去metadata-complete="true"即可
3. Servlet 3.0(Tomcat 7.x)
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="3.0" 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">
<display-name>Web Application</display-name>
</web-app>
4. Servlet 2.5(Tomcat 6.x)
<?xml version="1.0″ encoding="UTF-8″?>
<web-app version="2.5″ xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
<display-name>Web Application</display-name>
</web-app>
5. Servlet 2.4
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.4" 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">
<display-name>Web Application</display-name>
</web-app>
6. Servlet 2.3
<!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>
<display-name>Web Application</display-name>
</web-app>
以上是关于Java Servlet 2.3/2.4/2.5/3.0/3.1/4.0 各web.xml文件的主要内容,如果未能解决你的问题,请参考以下文章
web.xml & web-fragment.xml (Servlet 2.3, 2.4, 2.5 + 3.0)模板
File Templates for web.xml & web-fragment.xml (Servlet 2.3, 2.4, 2.5 + 3.0)