Spring Security csrf的使用

1、在WebSecurityConfigurerAdapter配置类中不要配置(默认csrf是开启状态)

//.and().csrf().disable();     /* 关闭csrf防护 */

2、在登录页面加上一个隐藏域用于记录csrftoken(用来thymeleaf模板引擎)

<input type="hidden" th:if="${_csrf}!=null" th:value="${_csrf.token}" name="_csrf">

猜你喜欢

转载自blog.csdn.net/magicproblem/article/details/112650764