JSF 2:可以在会话启动时初始化会话范围的Bean吗? [英] JSF 2: possible to initialize session-scoped beans on session start?

查看:132
本文介绍了JSF 2:可以在会话启动时初始化会话范围的Bean吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在JSF 2中,一旦加载了会话上下文,是否可以初始化一个会话范围的托管bean?我知道可以使用Application Scoped bean和@ManagedBean批注中的eager属性,但是会话bean是否存在类似的东西?我有一个会话范围的bean,无论是否访问了特定页面,我都希望加载它.

Is it possible in JSF 2 to initialize a session-scoped managed bean as soon as the session context is loaded? I know it's possible with Application Scoped beans and the eager attribute in the @ManagedBean annotation, but does something similar exist for session beans? I have a session-scoped bean that I want to have loaded regardless of if a specific page is visited.

推荐答案

您确定需要一个bean吗?如果是一些常规的初始化工作,则可以使用HttpSessionListener,然后在sessionCreated(..)上进行初始化.

Are you sure you need a bean? If it is some general initialization stuff, you can use a HttpSessionListener, and on sessionCreated(..) initialize things.

这篇关于JSF 2:可以在会话启动时初始化会话范围的Bean吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆