一些沒有結束標籤的元素會報錯,爲了解除這個限制,更符合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