### 1. 编写 失败注销用户处理器 并且继承 LogoutSuccessHandler 实现 onLogoutSuccess
~~~
@Component
public class WebLogoutSuccessHandler implements LogoutSuccessHandler {
@Override
public void onLogoutSuccess(HttpServletRequest request, HttpServletResponse response, Authentication authentication) throws IOException, ServletException {
System.out.println("退出登录");
}
}
~~~
### 2 .配置
~~~
/* http.logout()// 退出
.logoutSuccessHandler(logoutSuccessHandler) // 触发注销发生的请求匹配器
// 退出地址 只能设置一个
// .logoutUrl("/logout")
.logoutRequestMatcher(new AntPathRequestMatcher("/logout"));*/
//或者
http.logout().defaultLogoutSuccessHandlerFor(logoutSuccessHandler,new AntPathRequestMatcher("/logout"))
// 退出成功之前操作
.addLogoutHandler(logoutHandler);
~~~