Thymeleaf关闭标签不匹配报错

avatar 2018年05月24日03:34:29 6 3209 views
博主分享免费Java教学视频,B站账号:Java刘哥 ,长期提供技术问题解决、项目定制:本站商品点此
SpringBoot 使用 Thymeleaf 时,如果 HTML 标签不配对,会报错。

解决方便又两个

方法一、升级新版本

好像现在 3 版本已经自动关掉了

所以

1、application.properties
  1. spring.thymeleaf.mode=HTML5



2、pom.xml
  1. <properties>
  2.       <!--添加如下两行代码指定Thymeleaf标签的版本-->
  3.       <thymeleaf.version>3.0.2.RELEASE</thymeleaf.version>
  4.       <thymeleaf-layout-dialect.version>2.0.5</thymeleaf-layout-dialect.version>
  5.   </properties>

  1. <dependency>
  2.     <groupId>org.springframework.boot</groupId>
  3.     <artifactId>spring-boot-starter-thymeleaf</artifactId>
  4. </dependency>





方法二、修改模式为LEGACYHTML5

1、application.properties
  1. spring.thymeleaf.mode=LEGACYHTML5



2、pom.xml
  1. <dependency>
  2.     <groupId>org.springframework.boot</groupId>
  3.     <artifactId>spring-boot-starter-thymeleaf</artifactId>
  4. </dependency>
  5. <dependency>
  6.     <groupId>net.sourceforge.nekohtml</groupId>
  7.     <artifactId>nekohtml</artifactId>
  8.     <version>1.9.22</version>
  9. </dependency>





  • 微信
  • 交流学习,服务定制
  • weinxin
  • 个人淘宝
  • 店铺名:言曌博客咨询部

  • (部分商品未及时上架淘宝)
avatar

发表评论

avatar 登录者:匿名
匿名评论,评论回复后会有邮件通知

  

已通过评论:0   待审核评论数:0