由IDEA选择的版本2.1.16切换成1.5.10版本时,发现在项目正常启动时跳转themeleaf页面访问不到,报404。

image
查看控制报错日志:

image
发现是html文件解析错误
SpringBoot中thymeleaf的默认版本为:1.5.10.RELEAS
org.springframework.bootspring-boot-starter-validation1.5.10.RELEASE
第一种办法就是加上结束标签。
第二种办法就是在pom.xml中的 properties 中指明Thymeleaf标签的版本号即可。
UTF-8UTF-81.83.0.2.RELEASE2.0.5
第三种办法是在pom.xml中添加依赖。
org.springframework.bootspring-boot-starter-thymeleafnet.sourceforge.nekohtmlnekohtml1.9.22
application.properties中:
spring.thymeleaf.mode=LEGACYHTML5
推荐使用方法三。
注意:第二种办法可能在springsecurity中的一些标签不起作用。