0
我在我的JSF应用程序中有一个注销链接,它使会话无效以将用户注销。它可以工作,但不会将用户重定向到登录页面。它保持在同一页面上。如果我尝试再次访问相同的页面,它会直接返回到登录状态。我希望这会立即发生。注销commandLink将用户注销,但不更新页面
退出链接:
<h:form>
<h:panelGroup id="loginout">
<h:outputText value="#{todoController.loggedInUser}" />
<h:commandLink value="logout" action="#{todoController.logout}" />
</h:panelGroup>
</h:form>
注销代码:
public String logout()
{
System.out.println("testing logout");
FacesContext fc = FacesContext.getCurrentInstance();
ExternalContext ec = fc.getExternalContext();
final HttpServletRequest r = (HttpServletRequest)ec.getRequest();
r.getSession(false).invalidate();
return "../login.html?faces-redirect=true";
}
谢谢。这工作。但是,如果尝试在重定向后登录,则会出现“HTTP状态408错误 - 已超出登录过程所允许的时间”。我已经重定向到原始页面,然后跳转到登录页面,因为您不再登录。 :-) – Dana