javaweb中mapping的优先级问题

<?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>

javaweb中mapping的优先级问题

上一篇:jQuery使用appendTo()和remove()函数实现动态添加和删除行数据功能


下一篇:Android修改分析:默认属性修改