url-pattern含义

    xiaoxiao2021-12-14  19

    首先说下,其实url-pattern就是说的url模式,就是容器在查找时根据这个模式来找到具体的servlet来执行。

    先来看一段规范中的

    In the Web application deployment descriptor, the following syntax is used to define mappings:

    A string beginning with a ‘/’ character and ending with a ‘/*’ suffix is used for path mapping. A string beginning with a ‘*.’ prefix is used as an extension mapping. A string containing only the ’/’ character indicates the "default" servlet of the application.  All other strings are used for exact matches only.--这一句不是规范

    翻译下来就是:

    在web.xml文件中,以下语法用于定义映射:

    以”/’开头和以”/*”结尾的是用来做路径映射的。

    以前缀”*.”开头的是用来做扩展映射的。如*.action

     “/” 是用来定义default servlet映射的。

    其它所的有就是用来精确匹配的。

    但是有时我们也能够遇到/app/**的,这种情况下一般是Ant的表示语法,也是精确匹配(见标注)

    这个可以参考:

    http://stackoverflow.com/questions/13843294/what-does-the-double-wildcard-on-a-servlet-mapping-url-pattern-mean
    转载请注明原文地址: https://ju.6miu.com/read-963837.html

    最新回复(0)