我正在开发一个基于 Java 的 Web 应用程序。我们正在使用Guice
它ServletModule
来配置 servlet 和过滤器。
现在,Filter
即使通过调度程序转发请求,我也需要调用 a ,而不仅仅是传入请求。
在一个普通的 JEE Web 应用程序中,我可能会web.xml
这样设置......
<filter>
<filter-name>SomeFilter</filter-name>
<filter-class>com.acme.SomeFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>SomeFilter</filter-name>
<url-pattern>/*</url-pattern>
<dispatcher>REQUEST</dispatcher>
<dispatcher>FORWARD</dispatcher>
</filter-mapping>
但是我不能在 Guice 做同样的事情,我只能写这样的东西......
filter("/*").through(com.acme.SomeFilter.class);
...在我看来,我无法明确指定FORWARD
模式。因此,转发请求时过滤器不会启动。
你知道我是否可以在 Guice 中实现这一点?
提前致谢。