springboot项目使用thymeleaf时出现以上错误,原因及解决方法:
原因:在使用springboot的过程中,如果使用thymeleaf作为模板文件,则要求HTML格式必须为严格的html5格式,必须有结束标签,否则会报错。在application.yml中添加以下配置:
spring:
thymeleaf:
prefix: classpath:/templates/
mode: HTML
cache: false
encoding: UTF-8
# 新版本不支持content-type: text/html,故新写法
servlet:
content-type: text/html