从JSF请求中检索会话ID值

问题描述 投票:17回答:2

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

java session jsf
2个回答
41
投票
FacesContext fCtx = FacesContext.getCurrentInstance();
HttpSession session = (HttpSession) fCtx.getExternalContext().getSession(false);
String sessionId = session.getId();

0
投票

你试试

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

此行返回facesContext sessionId值

© www.soinside.com 2019 - 2024. All rights reserved.