【发布时间】:2010-10-20 19:52:47
【问题描述】:
如何在 JSF 托管 bean 中检索会话 ID 值?
【问题讨论】:
如何在 JSF 托管 bean 中检索会话 ID 值?
【问题讨论】:
FacesContext fCtx = FacesContext.getCurrentInstance();
HttpSession session = (HttpSession) fCtx.getExternalContext().getSession(false);
String sessionId = session.getId();
【讨论】:
你试试
{
String uuidFc = FacesContext.getCurrentInstance().getExternalContext().getSessionId(true);
}
此行返回 facesContext sessionId 值
【讨论】:
您也可以使用OmniFaces JSF utility library。
String sessionId = Faces.getSessionId();
添加这个作为答案,因为如果你使用 JSF,你很可能会使用这个库。
【讨论】: