Last time when I was working with Spring, the logout was handled in such a way:
<http auto-config="true">
...
<logout logout-success-url="/pages/login.xhtml?faces-redirect=true">
</http>
But now I'm doing it in pure J2EE way, thus this is what I got:
<h:form>
<p:commandbutton action="#{myController.logout}" value="logout" />
</h:form>
@ManagedBean
@RequestScoped
public class MyController {
...
...
public void logout() throws IOException {
ExternalContext ec = FacesContext.getCurrentInstance().getExternalContext();
ec.invalidateSession();
ec.redirect(ec.getRequestContextPath() + "/login.xhtml");
}
}
Notice the huge difference? With Spring, one statement rules the world.
No comments:
Post a Comment