web.xml:

web.xml 的 <dispatcher><filter-mapping> 下的子標籤,指定 Filter 對應的請求方式,其可選值以下:web

  • REQUEST 客戶端在地址欄直接請求時,則經過該過濾器。(默認值)
  • INCLUDE 經過 RequestDispatcher 的 include() 方法請求時。
  • FORWARD 經過 RequestDispatcher 的 forward() 方法請求時。
  • ERROR 當聲明產生異常時。

好比,當要經過來自「地址欄的請求」和「<jsp:forward page="/action"></jsp:forward>請求」時,便須要以下定義:app

<filter-mapping>
    <dispatcher>REQUEST</dispatcher>
    <dispatcher>FORWARD</dispatcher>
</filter-mapping>
相關文章
相關標籤/搜索