, 참조 : Spring security authenticate exceptions handling
그냥 error1하거나 있고 Error2, 구현은 단순한 리디렉션 방법이 될 수있는 사용자를 리디렉션하려면 다음
public class CustomAuthenticationFailureHandler extends SimpleUrlAuthenticationFailureHandler {
@Override
public void onAuthenticationFailure(HttpServletRequest request, HttpServletResponse response, AuthenticationException exception) throws IOException, ServletException {
super.onAuthenticationFailure(request, response, exception);
if(exception.getClass().isAssignableFrom(UsernameNotFoundException.class)) {
response.sendRedirect("error1")
} else if (exception.getClass().isAssignableFrom(LockedException.class)) {
response.sendRedirect("error2")
}
}
}
방법 그 클래스를 사용하도록 Spring을 설정합니까? @Component로 주석 달기를 시도하고 XML 구성을 pom.xml에 추가하려고 시도했다. 'authentication-failure-handler-ref는 허용되지 않습니다. '라는 불평을합니다. –
@Atte pom.xml이 아닌 application-security.xml에 구성해야합니다. pom.xml은 주로 종속성, 플러그인 및 프로파일을 추가하기위한 것입니다. –
좋아, 내가 찾은 몇 가지 예에 따라 application-security.xml 파일을 설정하려고했지만 여전히 작동하지 않습니다. 그 파일에 정의 된 문서가없는 것 같습니다. –