欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

詳解Spring mvc ant path的使用方法

 更新時間:2017年08月31日 11:23:59   作者:carl-zhao  
這篇文章主要介紹了詳解Spring mvc ant path的使用方法的相關(guān)資料,希望大家通過本文能掌握這部分內(nèi)容,需要的朋友可以參考下

詳解Spring mvc ant path的使用方法

概要:

任何一個WEB都需要解決URL與請求處理器之間的映射,spring MVC也是一樣,但Spring MVC就像Spring所作的一切一樣(靈活,可以配置各種東西,但是也造成了很多復(fù)雜性),肯定不會只有一種方法來映射URL和 Controller之間的關(guān)系,并且在實際上,允許你自己創(chuàng)建映射規(guī)則和實現(xiàn),而不僅僅依賴URL映射。

1、Spring path match

Spring MVC中的路徑匹配要比標準的web.xml要靈活的多。默認的策略實現(xiàn)了 org.springframework.util.AntPathMatcher,就像名字提示的那樣,路徑模式是使用了Apache Ant的樣式路徑,Apache Ant樣式的路徑有三種通配符匹配方法(在下面的表格中列出)這些可以組合出很多種靈活的路徑模式。

2、Apache ant type

下面就來描述一下apache ant匹配規(guī)則,其實還是挺簡單的。

Ant通配符描述

Wildcard Description
? 匹配任何單字符
* 匹配0或者任意數(shù)量的字符
** 匹配0或者更多的目錄

3、舉例說明:

1、 /views/products/**/*.cfm

# Matches
/views/products/index.cfm
/views/products/SE10/index.cfm
/views/products/SE10/details.cfm
/views/products/ST80/index.cfm
/views/products/ST80/details.cfm

# Does Not Match:
/views/index.cfm
/views/aboutUs/index.cfm
/views/aboutUs/managementTeam.cfm

2、 /views/**/*.cfm

# Matches:
/views/index.cfm
/views/aboutUs/index.cfm
/views/aboutUs/managementTeam.cfm
/views/products/index.cfm
/views/products/SE10/index.cfm
/views/products/SE10/details.cfm
/views/products/ST80/index.cfm
/views/products/ST80/details.cfm

# Does Not Match:
/views/index.htm
/views/readme.txt

3、 /views/index??.cfm

# Matches:
/views/index01.cfm
/views/index02.cfm
/views/indexAA.cfm

# Does Not Match:
/views/index01.htm
/views/index1.cfm
/views/indexA.cfm
/views/indexOther.cfm
/views/anotherDir/index01.cfm

如果知道這些我們就能夠在Spring MVC靈活的配置url映射了。

如有疑問請留言或者到本站社區(qū)交流討論,感謝閱讀,希望能幫助到大家,謝謝大家對本站的支持!

相關(guān)文章

最新評論