我为请求创建了不同的Filter。我在web.xml中完成了以下配置:
<servlet>
<servlet-name>jersey</servlet-name>
<servlet-class>com.sun.jersey.spi.container.servlet.ServletContainer</servlet-class>
<init-param>
<param-name>com.sun.jersey.api.json.POJOMappingFeature</param-name>
<param-value>true</param-value>
</init-param>
<init-param>
<param-name>com.sun.jersey.spi.container.ContainerRequestFilters</param-name>
<param-value>com.core.api.filter.Filter1</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>jersey</servlet-name>
<url-pattern>/v1/*</url-pattern>
</servlet-mapping>
<servlet>
<servlet-name>jersey</servlet-name>
<servlet-class>com.sun.jersey.spi.container.servlet.ServletContainer</servlet-class>
<init-param>
<param-name>com.sun.jersey.api.json.POJOMappingFeature</param-name>
<param-value>true</param-value>
</init-param>
<init-param>
<param-name>com.sun.jersey.spi.container.ContainerRequestFilters</param-name>
<param-value>com.core.api.filter.Filter2</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>jersey</servlet-name>
<url-pattern>/v2/*</url-pattern>
</servlet-mapping>
但是在服务器启动时我遇到了异常:
... 6 more
引起:javax.naming.NameNotFoundException:com - service jboss.naming.context.java.com 在org.jboss.as.naming.ServiceBasedNamingStore.lookup(ServiceBasedNamingStore.java:106) 在org.jboss.as.naming.NamingContext.lookup(NamingContext.java:207) at org.jboss.as.naming.InitialContext $ DefaultInitialContext.lookup(InitialContext.java:235) 在org.jboss.as.naming.NamingContext.lookup(NamingContext.java:193) 在org.jboss.as.naming.NamingContext.lookup(NamingContext.java:189) 在javax.naming.InitialContext.lookup(InitialContext.java:417) 在javax.naming.InitialContext.lookup(InitialContext.java:417) 在com.sun.jersey.server.impl.cdi.CDIExtension $ 2.stepInto(CDIExtension.java:311) at com.sun.jersey.server.impl.cdi.CDIExtension.diveIntoJNDIContext(CDIExtension.java:288) at com.sun.jersey.server.impl.cdi.CDIExtension.lookupJerseyConfigJNDIContext(CDIExtension.java:308) 在com.sun.jersey.server.impl.cdi.CDIExtension.getInitializedExtension(CDIExtension.java:231) ......还有23个
16:20:25,252 ERROR [org.jboss.as.controller.management-operation](控制器启动线程)WFLYCTL0013:操作(“部署”)失败 - 地址:
我试着去谷歌,但没有找到太多帮助。
请帮我解决这个问题......
先谢谢
答案 0 :(得分:1)
如果您需要使用两个不同的过滤器,则可能需要使用<filter-mapping>
标记。
来自this:
<filter>
<filter-name>Compression Filter</filter-name>
<filter-class>CompressionFilter</filter-class>
<init-param>
<param-name>compressionThreshold</param-name>
<param-value>10</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>Compression Filter</filter-name>
<servlet-name>CompressionTest</servlet-name>
</filter-mapping>
<servlet>
<servlet-name>CompressionTest</servlet-name>
<servlet-class>CompressionTest</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>CompressionTest</servlet-name>
<url-pattern>/CompressionTest</url-pattern>
</servlet-mapping>