从JSF请求中检索会话ID值

时间:2009-04-21 13:17:49

标签: java session jsf

如何在JSF托管bean中检索会话ID值?

2 个答案:

答案 0 :(得分:40)

FacesContext fCtx = FacesContext.getCurrentInstance();
HttpSession session = (HttpSession) fCtx.getExternalContext().getSession(false);
String sessionId = session.getId();

答案 1 :(得分:0)

您尝试

{String uuidFc = FacesContext.getCurrentInstance()。getExternalContext()。getSessionId(true); }

此行返回facesContext sessionId值