今天按照
《JavaEE开发的颠覆者: Spring Boot实战》
学习spring boot的时候在编写7_2时thymeleaf传参的时候发生500错误,通过查找各方面资料,发现书上的springboot版本(1.3.0)和我用的版本(2.1.7)不一样引起的
以下处理方法:
1. 将springboot版本改成2.0.5
2. 3.x版本的thymeleaf为了防止注入攻击,升级了安全机制
解决
修改前
<button th:onclick="‘javascript:getName(this,\‘‘+${person.name}+‘\‘);‘" type="button">获得名字</button>
修改后
<button th:data-name="${person.name}" onclick="getName(this,this.getAttribute(‘data-name‘))" type="button">获得名字</button>
原文地址:https://www.cnblogs.com/Treesir/p/11357634.html
时间: 2024-08-01 10:05:41