Spring和Thymeleaf的登出链接 [英] Logout link with Spring and Thymeleaf

查看:135
本文介绍了Spring和Thymeleaf的登出链接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

根据官方示例(保护Web内容),我必须使用一个旨在通过Spring Security执行注销的表单和按钮. 有没有办法使用Thymeleaf的链接而不是按钮?

According with the official example (Secure Web Content), I have to use a form and a button with the aim to perform a logout with Spring Security. Is there a way to use a link with Thymeleaf instead of a button?

推荐答案

解决方案(已弃用!)是:

The solution (deprecated!) is:

       .logout()
            .logoutRequestMatcher(new AntPathRequestMatcher("/logout"))
                .logoutSuccessUrl("/login");

如上所述,出于安全性考虑,建议使用POST而不是GET请求.

It is recommended to use POST instead of a GET request for security, as mentioned above.

这篇关于Spring和Thymeleaf的登出链接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆