Java 从 JSF 请求中检索会话 ID 值
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/772541/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Retrieving session ID value from a JSF request
提问by Veera
How do I retrieve the session ID value inside a JSF managed bean?
如何在 JSF 托管 bean 中检索会话 ID 值?
采纳答案by Damo
FacesContext fCtx = FacesContext.getCurrentInstance();
HttpSession session = (HttpSession) fCtx.getExternalContext().getSession(false);
String sessionId = session.getId();
回答by Pedro Alexander Cárdenas Rueda
You try
你试试
{String uuidFc = FacesContext.getCurrentInstance().getExternalContext().getSessionId(true); }
{String uuidFc = FacesContext.getCurrentInstance().getExternalContext().getSessionId(true); }
This line return the facesContext sessionId value
此行返回 facesContext sessionId 值