一些没有结束标签的元素会报错,为了解除这个限制,更符合html5标准,需要作如下处理:
方案一:
1.application.yml
添加配置
spring:
thymeleaf:
content-type: text/html
cache: false
mode: LEGACYHTML5
2.pom文件添加配置:
<!--允许不严格的html5格式出现-->
<dependency>
<groupId>net.sourceforge.nekohtml</groupId>
<artifactId>nekohtml</artifactId>
<version>1.9.22</version>
</dependency>
方案二:
<properties>
<!--解决没有结束标签报错问题-->
<thymeleaf.version>3.0.2.RELEASE</thymeleaf.version>
<thymeleaf-layout-dialect.version>2.0.5</thymeleaf-layout-dialect.version>
</properties>
#===============================================#
# thymeleaf 页面模板引擎配置 #
#===============================================#
# Enable template caching.
spring.thymeleaf.cache=false
# Check that the templates location exists.
spring.thymeleaf.check-template-location=true
# Content-Type value.
spring.thymeleaf.content-type=text/html
# Enable MVC Thymeleaf view issueResolution.
spring.thymeleaf.enabled=true
# Template encoding.
spring.thymeleaf.encoding=UTF-8
# Comma-separated list of view names that should be excluded from issueResolution.
# spring.thymeleaf.excluded-view-names=
# Template mode to be applied to templates. See also StandardTemplateModeHandlers.
spring.thymeleaf.mode=HTML5
# Prefix that gets prepended to view names when building a URL.
spring.thymeleaf.prefix=classpath:/templates/
# Suffix that gets appended to view names when building a URL.
spring.thymeleaf.suffix=.html