JSF 2.0中的单入口/出口点设计

编程入门 行业动态 更新时间:2024-10-12 14:22:28
本文介绍了JSF 2.0中的单入口/出口点设计的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我想在JSF 2.0中为所有请求和响应设计具有单个入口/出口点的应用程序,以便可以通过单个ManagedBean/控制器路由它们.

I want to design my application in JSF 2.0 with single entry/exit point for all the requests and responses so that they can be routed through a single managedBean/controller.

进行这种设计的目的是在一个普通的地方捕获我所有的业务异常,而且对我来说,为每个新请求检查会话的有效性也很容易.

The purpose of having this design is to catch my all business exceptions at common place and also it would be easy for me to check for the validation of session for each new request.

我看到的选项之一是ServletFilter,但是我不确定这是否是JSF 2.0的最佳方法.

One of the option I see is ServletFilter but I am not sure if this would be the best approach with JSF 2.0.

推荐答案

进行此设计的目的是在同一个地方捕获我所有的业务异常

只需实现自定义JSF ExceptionHandler

Just implement a custom JSF ExceptionHandler.

,对我来说,为每个新请求检查会话的有效性也很容易.

这没有任何意义.容器本身已经完成了操作.我相信您是在具体要求检查代表登录用户的会话属性.为此,servlet Filter确实是最明智的方法.某些人可能为此选择使用JSF PhaseListener,但这与JSF请求紧密结合,不会在其他请求上出现.

This makes no sense. The container does it already by itself. I believe that you're concretely asking to check a session attribute representing the logged-in user. For that a servlet Filter is indeed the most sensible approach. Some may opt to use a JSF PhaseListener for that, but this is tight coupled to JSF requests and does not kick in on other requests.

更多推荐

JSF 2.0中的单入口/出口点设计

本文发布于:2023-11-25 20:33:33,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1631250.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:入口   JSF

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!