在我的JSF应用程序中,我得到的用户这样当前登录的名字......使用session.invalidate的JSF注销不会清除当前的用户名?
public String getLoggedInUsername() {
return FacesContext.getCurrentInstance().getExternalContext().getRemoteUser();
}
...我检查用户是否喜欢这个签署...
public boolean isSignedIn() {
return (getLoggedInUsername() != null);
}
...当用户登出后,我做到这一点...
public String doLogout() {
FacesContext facesContext = FacesContext.getCurrentInstance();
HttpSession httpSession = (HttpSession)facesContext.getExternalContext().getSession(false);
httpSession.invalidate();
return "main";
}
我的问题是doLogout()时,getLoggedInUsername()仍然返回在登录的用户名之后。什么我应该这样做,以确保注销后getRemoteUser()返回null?
另外,是否有更好的方式来获得如果isSignedIn()比只检查用户名?
谢谢! Rob
您是否调试过涉及的方法本身,或者您是否基于Web浏览器的行为方式自己猜测/归纳它?该页面可能是从浏览器缓存中的普通请求... – BalusC 2011-02-04 15:10:48