url-pattern含义

来源:互联网 发布:网络监控 编辑:程序博客网 时间:2024/06/17 05:16

首先说下,其实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

0 0
原创粉丝点击