【发布时间】:2016-03-10 23:24:55
【问题描述】:
基于Spring security java的配置是(不是spring mvc,只是servlet webapp)
@Override
protected void configure(HttpSecurity http) throws Exception {
http
.authorizeRequests()
.anyRequest().authenticated()
.and()
.formLogin()
.loginPage("/login.jsp")
.permitAll();
}
登录页面是
<form name='loginForm' action="" method='POST'>
<c:if test="${param.logout != null}">
<p>You have been logged out.</p>
</c:if>
<table>
<tr>
<td>User:</td>
<td><input type='text' name='username'></td>
</tr>
<tr>
<td>Password:</td>
<td><input type='password' name='password' /></td>
</tr>
<tr>
<td colspan='2'><input name="submit" type="submit"
value="submit" /></td>
</tr>
</table>
<input type="hidden" name="${_csrf.parameterName}" value="${_csrf.token}" />
</form>
还有其他页面有注销链接,所以注销操作是logout(第2页)
<form action="logout" method="post">
<input type="submit" value="Logout" />
<input type="hidden" name="${_csrf.parameterName}" value="${_csrf.token}"/>
</form>
在我成功登录然后按下注销按钮(从第 2 页开始)后,它返回到登录页面,但登录页面没有显示注销消息 <c:if test="${param.logout != null}">。之后我尝试再次登录但它没有工作(它只是在注销后登录)并向我显示了一条注销消息。为什么它会这样工作以及如何修复它以在按下注销后立即显示注销消息。
【问题讨论】:
-
是什么让您相信参数
param.logout存在? - 你有任何描述/使用它的文档或教程吗?