posts - 73,  comments - 55,  trackbacks - 0
          2.4版本的servlet規范在部屬描述符中新增加了一個<dispatcher>元素,這個元素有四個可能的值:即REQUEST,FORWARD,INCLUDE和ERROR,可以在一個<filter-mapping>元素中加入任意數目的<dispatcher>,使得filter將會作用于直接從客戶端過來的request,通過forward過來的request,通過include過來的request和通過<error-page>過來的request。如果沒有指定任何< ? dispatcher ? >元素,默認值是REQUEST。可以通過下面幾個例子來輔助理解。 ?
          ? 例1: ?
          ? <filter-mapping> ?
          ? <filter-name>Logging ? Filter</filter-name> ?
          ? <url-pattern>/products/*</url-pattern> ?
          ? </filter-mapping> ?
          ? 這種情況下,過濾器將會作用于直接從客戶端發過來的以/products/…開始的請求。因為這里沒有制定任何的< ? dispatcher ? >元素,默認值是REQUEST。 ?
          ? ?
          ? 例2: ?
          ? <filter-mapping> ?
          ? ? ? ? ? ? ? ? ? <filter-name>Logging ? Filter</filter-name> ?
          ? ? ? ? ? ? ? ? ? <servlet-name>ProductServlet</servlet-name> ?
          ? ? ? ? ? ? ? ? ? <dispatcher>INCLUDE</dispatcher> ?
          ? </filter-mapping> ?
          ? 這種情況下,如果請求是通過request ? dispatcher的include方法傳遞過來的對ProductServlet的請求,則要經過這個過濾器的過濾。其它的諸如從客戶端直接過來的對ProductServlet的請求等都不需要經過這個過濾器。 ?
          ? 指定filter的匹配方式有兩種方法:直接指定url-pattern和指定servlet,后者相當于把指定的servlet對應的url-pattern作為filter的匹配模式 ?
          ? filter的路徑匹配和servlet是一樣的,都遵循servlet規范中《SRV.11.2 ? Specification ? of ? Mappings》一節的說明 ?
          ? ?
          ? 例3: ?
          ? <filter-mapping> ?
          ? ? ? ? ? ? ? ? ? <filter-name>Logging ? Filter</filter-name> ?
          ? ? ? ? ? ? ? ? ? <url-pattern>/products/*</url-pattern> ?
          ? ? ? ? ? ? ? ? ? <dispatcher>FORWARD</dispatcher> ?
          ? ? ? ? ? ? ? ? ? <dispatcher>REQUEST</dispatcher> ?
          ? </filter-mapping> ?
          ? 在這種情況下,如果請求是以/products/…開頭的,并且是通過request ? dispatcher的forward方法傳遞過來或者直接從客戶端傳遞過來的,則必須經過這個過濾器。??
          posted on 2006-12-22 08:46 保爾任 閱讀(835) 評論(0)  編輯  收藏 所屬分類: J2SE

          <2006年12月>
          262728293012
          3456789
          10111213141516
          17181920212223
          24252627282930
          31123456

          常用鏈接

          留言簿(4)

          隨筆分類

          隨筆檔案

          文章分類

          文章檔案

          搜索

          •  

          最新評論

          閱讀排行榜

          評論排行榜

          主站蜘蛛池模板: 石棉县| 蓝田县| 福泉市| 嵊泗县| 灵石县| 东莞市| 巴楚县| 台北市| 常熟市| 绥江县| 康乐县| 新宾| 城步| 咸阳市| 元谋县| 红原县| 普格县| 郧西县| 兰西县| 左云县| 鄂尔多斯市| 玉门市| 白银市| 黄骅市| 松原市| 交城县| 南投市| 万盛区| 平顶山市| 河间市| 应用必备| 道真| 梨树县| 常宁市| 锦屏县| 吉木乃县| 包头市| 杭锦后旗| 浙江省| 莲花县| 孝感市|