我有这个xhtml:
<p:menuitem value="Sair" url="login.jsf" icon="sair" action="#{loginBean.invalidaSessao()}"/>
和这个Bean:
public void invalidaSessao() {
System.out.println("Chamou...");
FacesContext.getCurrentInstance().getExternalContext().getSessionMap().remove("loginBean");
NavigationHandler handler = FacesContext.getCurrentInstance().getApplication().getNavigationHandler();
logout();
handler.handleNavigation(FacesContext.getCurrentInstance(), null, "login.jsf");
FacesContext.getCurrentInstance().renderResponse();
}
和过滤器;
@WebFilter(servletNames={"Faces Servlet"}) // Must match <servlet-name> of your FacesServlet.
public class NoCacheFilter implements Filter {
@Override
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
HttpServletRequest req = (HttpServletRequest) request;
HttpServletResponse res = (HttpServletResponse) response;
System.out.print("Chamou!!!");
if (!req.getRequestURI().startsWith(req.getContextPath() + ResourceHandler.RESOURCE_IDENTIFIER)) { // Skip JSF resources (CSS/JS/Images/etc)
res.setHeader("Cache-Control", "no-cache, no-store, must-revalidate"); // HTTP 1.1.
res.setHeader("Pragma", "no-cache"); // HTTP 1.0.
res.setDateHeader("Expires", 0); // Proxies.
}
chain.doFilter(request, response);
}
我可以退出该应用程序,但我可以返回浏览器按钮。