上下文已损坏,但会话仍然打开
我是 jsf 的新手,我读到会话可以被销毁
FacesContext fc = FacesContext.getCurrentInstance();
HttpSession session = (HttpSession) fc.getExternalContext().getSession(false);
fc.getExternalContext().getSessionMap().clear();
session.invalidate();
我的问题是,在执行此操作之后,会话仍然处于活动状态,并使用以下 bean:
com.sun.faces.renderkit.ServerSideStateHelper.LogicalViewMap
你有一个想法吗?
I'm new to jsf and I've read that a session can be destroyed
FacesContext fc = FacesContext.getCurrentInstance();
HttpSession session = (HttpSession) fc.getExternalContext().getSession(false);
fc.getExternalContext().getSessionMap().clear();
session.invalidate();
My problem ist, after doing that the session is still active, with the following bean :
com.sun.faces.renderkit.ServerSideStateHelper.LogicalViewMap
Do you have an idea?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这只是一个新会话。要亲自测试,请检查
HttpSession#getId()
请求期间invalidate前后。应该有所不同。与具体问题无关,每当您调用
invalidate()
时都不需要清除会话映射。无论如何,会话映射都会被丢弃。另请注意,getSession(false)
可能会返回null
,并且您希望添加额外的检查以避免NullPointerException
。或者直接使用getSession(true)
来代替。That's just a new session. To test it yourself, check the value of
HttpSession#getId()
during the request before and after invalidate. It should be different.Unrelated to the concrete question, clearing the session map is unnecessary whenever you call
invalidate()
. The session map will be trashed anyway. Also note thatgetSession(false)
can potentially returnnull
and you'd like to add an extra check to avoidNullPointerException
. Or just usegetSession(true)
instead.