### 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);
~~~