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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-11 19:18:23  来源:igfitidea点击:

Retrieving session ID value from a JSF request

javasessionjsf

提问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 值