url-pattern含義

首先說下,其實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

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章