CustomFailureHandler.java 文件源码

java
阅读 21 收藏 0 点赞 0 评论 0

项目:Spring-5.0-Cookbook 作者:
@Override
public void onAuthenticationFailure(HttpServletRequest request, HttpServletResponse response,
        AuthenticationException exception) throws IOException, ServletException {
    System.out.println("failure");
    String targetUrl = "";
    if(exception instanceof BadCredentialsException){
        targetUrl = "/login.html?error=" + exception.getMessage();
    }
    else {
        targetUrl = "/login.html?error=" + true;
    }

    if (response.isCommitted()) {
            System.out.println("Internal problem in redirection");
            return;
    }

    redirectStrategy.sendRedirect(request, response, targetUrl);
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号