使用请求调度程序的 Java 过滤器 - 使用 JavaEE 6 注解
我已经使用 JaveEE 6 注释为“/folder/*”创建了一个过滤器
@WebFilter("/folder/*")
,但是当我转到在 doGet 中有调用的“/test.html”时
request.getRequestDispatcher("/folder/test.jsp").forward(request, response);
,该页面不会被过滤。当在浏览器中手动访问“/folder/test.jsp”时,过滤器工作正常。使用调度程序时如何使其工作?
我找到了在多个地方创建过滤器的 xml 方式的解决方案,例如这里< /a> 或 此处 但一直无法找到使用注释的解决方案。谢谢!
I have created a filter for "/folder/*" using the JaveEE 6 Annotation
@WebFilter("/folder/*")
However when I go to "/test.html" which has a call
request.getRequestDispatcher("/folder/test.jsp").forward(request, response);
in the doGet, the page is not filtered. When going to "/folder/test.jsp" manually in the browser, the filter works fine. How can I make it work when using a dispatcher also?
I have found a solution for the xml way of creating filters multiple places such as here or here but have been unable to find a solution using annotations. Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
注释似乎有一个 dispatcherTypes 属性来支持这一点,因此以下内容应该有效:
The annotations seems to have a dispatcherTypes attribute to support this, so the following should work: