Spring和Thymeleaf的登出链接
问题内容:
根据官方示例(Secure Web Content),我必须使用一个表单和一个按钮,目的是通过Spring Security执行注销。有没有办法使用Thymeleaf的链接而不是按钮?
问题答案:
解决方案(不建议使用!)是:
.logout()
.logoutRequestMatcher(new AntPathRequestMatcher("/logout"))
.logoutSuccessUrl("/login");
如上所述,为了安全起见,建议使用POST而不是GET请求。