1、在WebSecurityConfigurerAdapter配置类中不要配置(默认csrf是开启状态)
//.and().csrf().disable(); /* 关闭csrf防护 */
2、在登录页面加上一个隐藏域用于记录csrftoken(用来thymeleaf模板引擎)
<input type="hidden" th:if="${_csrf}!=null" th:value="${_csrf.token}" name="_csrf">
本文介绍了如何在Spring Security中关闭CSRF防护,并在Thymeleaf模板中添加隐藏域来处理CSRFTOKEN,确保登录页面的安全交互。
1、在WebSecurityConfigurerAdapter配置类中不要配置(默认csrf是开启状态)
//.and().csrf().disable(); /* 关闭csrf防护 */
2、在登录页面加上一个隐藏域用于记录csrftoken(用来thymeleaf模板引擎)
<input type="hidden" th:if="${_csrf}!=null" th:value="${_csrf.token}" name="_csrf">
2279
3971

被折叠的 条评论
为什么被折叠?