0

在 jsf 中,我想将 sessionscope bean 注入到 actionlistener 实现中。可以做到吗?

4

2 回答 2

2

像这样:

YourBean testBean = (YourBean)FacesContext.getCurrentInstance().getExternalContext()
               .getSessionMap().get( "yourBean");
于 2011-06-26T17:56:49.710 回答
0

通过这个..

http://www.oio.de/public/java/jsf-best-practices-javaserver-faces-session-tips.htm

或者

    ELContext elContext = context.getELContext();
    context.getApplication().getExpressionFactory()
       .createValueExpression(elContext,"#{sessionScope.sessionValue}", String.class)
       .setValue(elContext, this.getSessionValue());
于 2011-06-27T05:22:25.610 回答