我正在Eclipse IDE上开发基于jsf的Web应用程序。我在登录和注销操作方面遇到了一些问题。 A.S是一个Weblogic。我可以成功登录并注销到应用程序,但是以下代码不会破坏会话......:
我的退出功能
public String logout() throws IOException {
FacesContext context = FacesContenter code hereext.getCurrentInstance();
ExternalContext ec = context.getExternalContext();
final HttpServletRequest request = (HttpServletRequest) ec.getRequest();
request.getSession(true).invalidate();
return ("logout");
}
faces-config.xml中
<navigation-rule>
<from-view-id>/home.xhtml</from-view-id>
<navigation-case>
<from-outcome>logout</from-outcome>
<to-view-id>/login.xhtml</to-view-id>
<redirect />
</navigation-case>
</navigation-rule>
记录主页
<body>
<h:form id="Form">
Hello<span style="color: ORANGE">
#{profileController.profile.name}</span>
<h:commandLink value="sign out" action="#{profileController.logout}" />
</h:form>
Web.xml中
<servlet>
<servlet-name>Faces Servlet</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.jsf</url-pattern>
</servlet-mapping>
<context-param>
<param-name>com.sun.faces.enableRestoreView11Compatibility</param-name>
<param-value>true</param-value>
</context-param>