我正在使用JSF2来开展一个项目。我使用Spring安全性进行身份验证(访问,登录和注销),我的查看页面是xhtml。我的问题是退出后用户可以回到上一页并做好工作。我使用AuthenticationBean类登录& louout。 另外,我将下面的命令添加到我的页面的标题,但没有任何改变!
meta http-equiv="Cache-control" content="public"
meta http-equiv="Cache-control" content="private"
meta http-equiv="Cache-control" content="no-cache"
meta http-equiv="Cache-control" content="no-store"
豆子:
@ManagedBean(name = "authenticationBean")
@RequestScoped
public class AuthenticationBean {
public String doLogin() throws ServletException, IOException {
ExternalContext context = FacesContext
.getCurrentInstance().getExternalContext();
RequestDispatcher dispatcher = ((ServletRequest) context.getRequest())
.getRequestDispatcher("/j_spring_security_check");
dispatcher.forward(
(ServletRequest) context.getRequest(),
(ServletResponse) context.getResponse());
FacesContext.getCurrentInstance().responseComplete();
return null;
}
public String doLogout() {
FacesContext.getCurrentInstance()
.getExternalContext().invalidateSession();
return "/login.xhtml";
}
}
<meta http-equiv="Pragma" content="no-cache"/>
<meta http-equiv="Expires" content="0"/>
<h:graphicImage library="images" name="spr-2.png" width="400" height="400"/>
<h:form id="loginForm" prependId="false">
<h:messages globalOnly="true"/>
<p:messages autoUpdate="true"/>
<h:panelGrid columns="3">
<h:outputLabel for="j_username" value="User: * " />
<p:inputText id="j_username" required="true" label="username" />
<h:outputLabel for="j_password" value="Password: * " />
<p:password id="j_password" label="password" required="true" />
</h:panelGrid>
<h:commandButton type="submit" id="login" value="Login" action="#{authenticationBean.doLogin()}" />
</h:form>
<f:facet name="first">
<meta http-equiv="X-UA-Compatible" content="IE=Edge" />
</f:facet>
</h:head>
<h:body>
<h:form>
<h:commandLink action="#{authenticationBean.doLogout}" style="font-size: 0.7em;color:blue;font-family:serif ">logout</h:commandLink>
</h:form>
<h:form>
<p:commandLink value="GO TO Functions" action="/pages/admin/indexAdmin?faces-redirect=true"/>
</h:form>
<h:graphicImage library="images" name="pic1.jpg" width="800" height="200"/> </h:body>
<meta http-equiv="Pragma" content="no-cache">
<meta http-equiv="Expires" content="0">