http://www.mkyong.com/spring-security/display- custom-error-message-in-spring-security/
Чтобы показать пользовательское сообщение об ошибке в форме входа, и я получил его в начало. Но после объявления authentication-failure-handler-ref="myAuthErrorHandler" для пользовательского обработчика проверки подлинности сбоя я не вижу этого специального сообщения в форме входа:

Что я делаю неправильный? Может ли кто-нибудь объяснить мне, что происходит и почему не отображается сообщение «Неверное имя пользователя или пароль»?
Вот код:
Прослушиватель аутентификации
Код: Выделить всё
public class AuthentificationListener implements AuthenticationFailureHandler {
@Override
public void onAuthenticationFailure(HttpServletRequest request,
HttpServletResponse response, AuthenticationException ae)
throws IOException, ServletException {
UsernamePasswordAuthenticationToken user = (UsernamePasswordAuthenticationToken) ae
.getAuthentication();
/* User */
response.sendRedirect(request.getContextPath()
+ "/abc/main/loginfailed");
}
applicationContext.xml:
Код: Выделить всё
Код: Выделить всё
Код: Выделить всё
Your login attempt was not successful, try again.
Caused :
${sessionScope["SPRING_SECURITY_LAST_EXCEPTION"].message}
Код: Выделить всё
@RequestMapping(value="/loginfailed", method = RequestMethod.GET)
public String loginerror(ModelMap model) {
model.addAttribute("error", "true");
return "login";
}
Код: Выделить всё
${sessionScope["SPRING_SECURITY_LAST_EXCEPTION"].message}
Подробнее здесь: https://stackoverflow.com/questions/211 ... ot-showing