如何:使用 javax.servlet.Filter 拦截 a4j 请求?
有谁知道如何使用 javax.servlet.Filter 拦截 a4j 请求? 拦截必须在调用 FacesServlet 之前发生(这就是我计划使用 Filter 来执行此操作的原因)。
我想知道哪个方法将在我的 backbean 上执行,因为我需要首先进行动态控制。
Does anybody know how to intercept a a4j request using a javax.servlet.Filter?
The interception must occur before FacesServlet be called (it's why I'm planning to do it using Filter).
I'd like to know which method will be executed on my backbean, cause I need to do a dynamic control first.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您想要确定 a4j 请求标记的请求标头。我不做 a4j,但如果它运行良好,您应该能够根据
X-Requested-With
标头确定它。然后只需在
if
块中确定该值是否是 a4j 请求的预期值并进行相应处理。如有必要,请不要忘记在末尾继续过滤器链。要让它运行,只需将其映射到
FacesServlet
的
上,因为它当前在web.xml
中定义。 。You'd like to determine the request headers for a marker of the a4j request. I don't do a4j, but if it is doing its work well, you should be able to determine it based on the
X-Requested-With
header.Then just determine in an
if
block if the value is the expected one for a4j requests and handle accordingly. Don't forget to continue the filter chain at end whenever neccessary.To get it to run, just map it on the
<servlet-name>
of theFacesServlet
as it is currently definied inweb.xml
.