【发布时间】:2011-11-01 04:11:27
【问题描述】:
我正在使用基于表单的身份验证。
我有一个注销链接,如下所示:
<h:commandLink action="#{loginBean.logout}">
<h:outputText value="logout" />
</h:commandLink></div>
以及对应的注销方式:
public String logout() {
FacesContext.getCurrentInstance().getExternalContext().invalidateSession();
return "/view/index?faces-redirect=true"; // Redirect added as per BalusC's suggestion.
}
点击注销链接后,我返回首页,但似乎没有 CSS。当我点击按钮运行搜索时,出现以下错误:
javax.faces.application.ViewExpiredException: viewId:/view/index.jsf - View /view/index.jsf could not be restored.
然而 CSS 实际上位于 /resources 下,据我了解我的 web.xml 不需要身份验证:
<security-constraint>
<web-resource-collection>
<web-resource-name>fizio</web-resource-name>
<url-pattern>/*</url-pattern>
<http-method>GET</http-method>
<http-method>POST</http-method>
</web-resource-collection>
<auth-constraint>
<role-name>*</role-name>
</auth-constraint>
</security-constraint>
<security-constraint>
<web-resource-collection>
<web-resource-name>Unprotected area</web-resource-name>
<url-pattern>/resources/*</url-pattern>
</web-resource-collection>
</security-constraint>
在这种状态下,我似乎能够再次登录并在偶尔的 view-could-not-be-restored 错误之间看到 一些 数据,但没有 CSS。真的有点崩溃了。任何建议将不胜感激。
ETA:登录表单:
<form method="POST" action="j_security_check">
<label for="j_password">Username:</label> <input type="text" name="j_username" />
<br />
<label for="j_password">Password:</label> <input type="password" name="j_password" /> <input type="submit" value="Login" />
</form>
【问题讨论】: