Spring boot + Spring Security + thymeleaf表单提交被拦截问题

xiaoxiao2021-02-28  55

问题描述

thymeleaf是一种前端模板,类似与freemaker,但是其文件格式是html格式,可以配合Spring boot一起使用,在使用Spring boot + Spring Security + thymeleaf整合时,默认情况下,使用Spring Security 时form表单如果不使用th:action标签,会出现无法提交的问题

问题解决

在Spring Security的配置中,加入配置:

@Override protected void configure(HttpSecurity http) throws Exception { //解决非thymeleaf的form表单提交被拦截问题 http.csrf().disable(); }

配置后form 使用普通的action也可正常提交

转载请注明原文地址: https://www.6miu.com/read-57548.html

最新回复(0)