Я взял ваш и немного изменил, и этот работает нормально для меня,
http
.csrf().disable()
.authorizeRequests()
.antMatchers("/403.xhtml").access("IS_AUTHENTICATED_ANONYMOUSLY")
.antMatchers("/wrecked-db.xhtml").access("ROLE_USER")
.antMatchers("/admin.xhtml").access("ROLE_ADMIN")
.antMatchers("/**.xhtml").access("NO_ACCESS")
.antMatchers("/login*").permitAll().anyRequest().authenticated()
.and().formLogin()
.loginPage("/login.html")
.loginProcessingUrl("/login")
.successHandler(new AuthenticationSuccessHandler() {
@Override
public void onAuthenticationSuccess(HttpServletRequest request, HttpServletResponse response, Authentication authentication) throws IOException, ServletException {
System.out.println("AuthenticationSuccessHandler");
}
})
.failureHandler(new AuthenticationFailureHandler() {
@Override
public void onAuthenticationFailure(HttpServletRequest request, HttpServletResponse response, AuthenticationException exception) throws IOException, ServletException {
System.out.println("AuthenticationFailureHandler");
}
})
.and().logout().logoutUrl("/logout.xhtml")
.logoutSuccessUrl("/login.xhtml")
.deleteCookies("JSESSIONID");
И моя страница входа будет выглядеть как
<form action="login" method='POST'>
<table>
<tr>
<td>UN</td>
<td><input type='text' name='username' value=''></td>
</tr>
<tr>
<td>Pass</td>
<td><input type='password' name='password' /></td>
</tr>
<tr>
<td><input name="submit" type="submit" value="submit" /></td>
</tr>
</table>
</form>