web.xml配置整理

來源:互聯網
上載者:User

標籤:style   blog   http   java   strong   html   

雖然是做web開發,但是web中的很多配置有的時候卻不是很清楚,只是知道怎麼配置,於是就把在網上看到各種關於web.xml的東西整理一下:

web.xml中url-pattern的3種寫法 
1完全符合
 

<url-pattern>/test/list.do</url-pattern>

2 路徑匹配 

<url-pattern>/*</url-pattern> <!--匹配根路徑下的全部請求-->

3副檔名匹配

  <url-pattern>*.do</url-pattern><!--匹配全部.do結尾的請求-->  <url-pattern>*.html</url-pattern> <!--匹配全部.html結尾的請求-->  <url-pattern>*</url-pattern> <!--不能用*,否則報錯-->
Filter 配置多個URL-PATTERN

原文參考(http://weidongke123-126-com.iteye.com/blog/1032546)

一、完全錯誤的方式 

<filter><filter-name>authority</filter-name><filter-class>com.util.AuthorityFilter</filter-class></filter><filter-mapping><filter-name>authority</filter-name><url-pattern>/pages/cmm/*;/pages/genbill/*</url-pattern></filter-mapping>

二、有一定作用,但不能實現需要的效果,只會過濾最下面配置的url-pattern。

<filter><filter-name>authority</filter-name><filter-class>com.util.AuthorityFilter</filter-class></filter><filter-mapping><filter-name>authority</filter-name><url-pattern>/pages/cmm/*</url-pattern>       <url-pattern>/pages/genbill/*</url-pattern></filter-mapping>

三、現在給出正確的配置方式 

<filter><filter-name>authority</filter-name><filter-class>com.util.AuthorityFilter</filter-class></filter><filter-mapping><filter-name>authority</filter-name>       <url-pattern>/pages/genbill/*</url-pattern></filter-mapping><filter-mapping><filter-name>authority</filter-name><url-pattern>/pages/cmm/*</url-pattern></filter-mapping>

 

 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.