1.写入session
Object sessionName = "name";
Object sessionValue = "value";
HttpSession session = (HttpSession)FacesContext.getCurrentInstance().getExternalContext().getSession(true);
session.setAttribute(sessionName,sessionValue);
2.获取session值
String getName = session.getAttribute("name").toString();
3.清除session
session.invalidate();
JSF session的用法
最新推荐文章于 2017-07-03 15:53:29 发布
本文介绍了在JavaServer Faces (JSF) 框架中如何进行Session的操作,包括写入Session、获取Session值以及清除Session的具体实现方式。通过简单的代码示例,展示了如何使用FacesContext来获取HttpSession,并对Session进行设置属性、读取属性和销毁等操作。
287

被折叠的 条评论
为什么被折叠?



