2017-05-30 56 views
0

我有我要在多個頁面上使用過濾器:的Java Servlet過濾器參數

<filter> 
    <filter-name>PermissionFilter</filter-name> 
    <filter-class>filters.PermissionFilter</filter-class> 
</filter> 
....... 
<filter-mapping> 
    <filter-name>PermissionFilter</filter-name> 
    <url-pattern>/faces/folder1</url-pattern> 
</filter-mapping> 
<filter-mapping> 
    <filter-name>PermissionFilter</filter-name> 
    <url-pattern>/faces/folder2</url-pattern> 
</filter-mapping> 

它可以指定過濾器映射參數(S)? 類似的東西:

<filter-mapping> 
    <filter-name>PermissionFilter</filter-name> 
    <url-pattern>/faces/folder2</url-pattern> 
    <init-param> 
    <param-name>permission</paramn-name> 
    <param-value>permssionNameWhichIWantToVerify</param-value> 
    </init-param> 

謝謝!

回答

0

不需要。您需要做的是爲每個想要使用的參數組合聲明一次過濾器,然後將正確的過濾器與正確的參數組合映射到相應的URL。