springMVC的<mvc:resources mapping="***" location="***">標(biāo)簽是在spring3.0.4出現(xiàn)的,,主要是用來(lái)定義對(duì)靜態(tài)資源的訪問(wèn),。 <!-- For static resources --> <mvc:resources mapping="/image/**" location="/images/" /> <mvc:resources mapping="/js/**" location="/js/" /> <mvc:resources mapping="/css/**" location="/css/" /> <mvc:resources mapping="/html/**" location="/html/" /> <mvc:resources mapping="/software/**" location="/software/" />
<mvc:resources location="/" mapping="/**/*.html"/> <mvc:resources location="/" mapping="/**/*.js"/> <mvc:resources location="/" mapping="/**/*.css"/> <mvc:resources location="/" mapping="/**/*.png"/> <mvc:resources location="/" mapping="/**/*.gif"/>
來(lái)源:http://blog.csdn.net/tlin2011/article/details/45482463 spring mvc 配置為: <servlet-mapping> 時(shí),當(dāng)直接訪問(wèn)png,jpg等資源時(shí),,也會(huì)攔截,, web.xml 加入如下配置 則web服務(wù)器會(huì)處理,不會(huì)被spring 攔截 親測(cè): <servlet-mapping>
另外: 不知為何加入<mvc:resources mapping="/images/**" location="/images/" /> 可以訪問(wèn)資源,,但是訪問(wèn)不了 controller了 |
|
來(lái)自: 青_春 > 《SpringMVC》