Can we access session scope variables directly in JSF xhtml files

倖福魔咒の 提交于 2020-02-20 08:26:10

问题


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?

Thanks


回答1:


Yes its possible

If the bean doesnot exits then put it in session first

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

And to use the bean on xhtml page use

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


来源:https://stackoverflow.com/questions/19445455/can-we-access-session-scope-variables-directly-in-jsf-xhtml-files

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!