java jersey multiple ServletContainer Filters

时间:2013-10-21 11:40:14

标签: java java-ee servlets jersey servlet-filters

我有这样的过滤器配置:

<filter>
    <filter-name>Jersey Web Application</filter-name>
    <filter-class>com.sun.jersey.spi.container.servlet.ServletContainer</filter-class>
    <init-param>
        <param-name>com.sun.jersey.config.property.WebPageContentRegex</param-name>
        <param-value>/(images|js|styles|(WEB-INF/jsp))/.*</param-value>
    </init-param>
    <init-param>
        <param-name>com.sun.jersey.config.property.JSPTemplatesBasePath</param-name>
        <param-value>/WEB-INF/jsp</param-value>
    </init-param>
    <init-param>
        <param-name>com.sun.jersey.config.property.packages</param-name>
        <param-value>pl.psnc.dl.wf4ever</param-value>
    </init-param>
    <init-param>
        <param-name>com.sun.jersey.spi.container.ContainerRequestFilters</param-name>
        <param-value>pl.psnc.dl.wf4ever.auth.SecurityFilter</param-value>
    </init-param>
</filter>

<filter-mapping>
    <filter-name>Jersey Web Application</filter-name>
    <url-pattern>/*</url-pattern>
</filter-mapping>

我想保留此过滤器

<param-value>pl.psnc.dl.wf4ever.auth.SecurityFilter</param-value>

但我需要添加下一个与此非常类似的过滤器。如何定义使用下一个fitler让我们说

 <param-value>pl.psnc.dl.wf4ever.auth.SecurityFilterAdmin</param-value>

1 个答案:

答案 0 :(得分:3)

请参阅Jersey API,您可以指定由;,或空格分隔的多个过滤器类。

<init-param>
    <param-name>com.sun.jersey.spi.container.ContainerRequestFilters</param-name>
    <param-value>foo.Bar;foo.Baz</param-value>
</init-param>