我们可以直接在JSF xhtml文件中访问会话范围变量吗 [英] Can we access session scope variables directly in JSF xhtml files

查看:101
本文介绍了我们可以直接在JSF xhtml文件中访问会话范围变量吗的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在研究一个JSF项目,我想直接在我的xhtml UI页面上访问一些会话级别的变量,而无需使用任何托管bean.

Hi I am working on a JSF project, I will like to access some session level variables onto my xhtml UI pages directly without using any managed bean.

只想知道这是否可行,是否可行?

Just wanted to know if this is possible and if yes than how?

谢谢

推荐答案

是可能的

如果Bean没有退出,请先将其放入会话

If the bean doesnot exits then put it in session first

FacesContext.getCurrentInstance().getExternalContext().getSessionMap().put(key,object);

要在xhtml页面上使用Bean,请使用

And to use the bean on xhtml page use

<h:outputText value="#{sessionScope.key}" /> 

这篇关于我们可以直接在JSF xhtml文件中访问会话范围变量吗的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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