当前位置: 代码迷 >> 综合 >> thymeleaf 模板使用 之 解决因HTML标签未闭合引起的错误
  详细解决方案

thymeleaf 模板使用 之 解决因HTML标签未闭合引起的错误

热度:84   发布时间:2023-12-02 06:01:10.0

 一、修改thymeleaf属性配置

spring.thymeleaf.prefix=classpath:/templates/
spring.thymeleaf.suffix=.html
spring.thymeleaf.mode=LEGACYHTML5
spring.thymeleaf.encoding=UTF-8
spring.thymeleaf.content-type=text/html
spring.thymeleaf.cache=false

 

二、添加依赖(LEGACYHTML5需要搭配一个额外的库NekoHTML才可用)

<dependency>
<groupId>net.sourceforge.nekohtml</groupId>
<artifactId>nekohtml</artifactId>
<version>1.9.22</version>
</dependency>

  相关解决方案