
8.自定义登录失败处理器
创建handle=》MyAuthenticationFailureHandle.java
/**
* @author etern
* @title: MyAuthenticationFailureHandle
* @projectName springsecuritydemo
* @description: TODO
* @date 2022/1/21 23:51
*/
public class MyAuthenticationFailureHandler implements AuthenticationFailureHandler {
private String url;
public MyAuthenticationFailureHandler(String url) {
this.url = url;
}
@Override
public void onAuthenticationFailure(HttpServletRequest request, HttpServletResponse response, AuthenticationException exception) throws IOException, ServletException {
response.sendRedirect(url);
}
}
SecurityConfig.java
//登录失败后处理器,不能和failureForwardUrl共存
.failureHandler(new MyAuthenticationFailureHandler("/error.html"));
位置截图:
本文是原创文章,采用 CC BY-NC-ND 4.0 协议,完整转载请注明来自 Eternal Night
评论
匿名评论
隐私政策
你无需删除空行,直接评论以获取最佳展示效果