问题
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