当我以新用户身份登录时,userBean 没有更新

userBean is not updated when I login as a new user

我有一个会话作用域用户 bean,它在应用程序启动时将用户数据加载到内存中。用户 bean 数据在整个应用程序中用于获取数据,即电子邮件等。

我注意到,如果我注销,旧的用户数据仍然会从 bean 中显示出来,这对关闭浏览器没有帮助。

我该如何解决这个问题?

我 运行 以下代码在注销时清除 sessionScope:

val = context.getSubmittedValue();
if (val == "logout") {
    facesContext.getExternalContext().getSession(false).invalidate();
    href=facesContext.getExternalContext().getRequest().getContextPath() + "?Logout&redirectTo=" + facesContext.getExternalContext().getRequest().getContextPath() ;
    facesContext.getExternalContext().redirect(href);
}