标签:优先 com sch tde xsd org app class version
<?xml version="1.0" encoding="UTF-8"?>
<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_4_0.xsd"
version="4.0"
metadata-complete="true">
<!--
优先级问题:先走固定映射,匹配不到再走默认映射
-->
<!--固定映射-->
<servlet>
<servlet-name>demo</servlet-name>
<servlet-class>com.pipi.servletcontext.ServletDemo01</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>demo</servlet-name>
<url-pattern>/test</url-pattern>
</servlet-mapping>
<!--默认映射-->
<servlet>
<servlet-name>sd2</servlet-name>
<servlet-class>com.pipi.servletcontext.ServletDemo02</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>sd2</servlet-name>
<url-pattern>/*</url-pattern>
</servlet-mapping>
<servlet>
<servlet-name>sd3</servlet-name>
<servlet-class>com.pipi.servletcontext.ServletDemo03</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>sd3</servlet-name>
<!--注意:正确写法-->
<url-pattern>*.do</url-pattern>
<!--注意:错误写法-->
<!--<url-pattern>/*.do</url-pattern>-->
</servlet-mapping>
</web-app>
标签:优先 com sch tde xsd org app class version
原文地址:https://www.cnblogs.com/pipilong/p/14350372.html