45fan.com - 路饭网

搜索: 您的位置主页 > 网络频道 > 阅读资讯:thymeleaf模板实现html5标签的非严格检查

thymeleaf模板实现html5标签的非严格检查

2019-03-26 15:51:29 来源:www.45fan.com 【

thymeleaf模板实现html5标签的非严格检查

一、概述

最近在springboot项目引入thymeleaf模板时,使用非严格标签时,运行会报错。默认thymeleaf模板对html5标签是严格检查的。

二、在项目中加NekoHTML库

在Maven中添加依赖

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

三、更改thymeleaf设置

在配置文件application.properties中,对thymeleaf模板设置。

LEGACYHTML5需要搭配NekoHTML库才可用,实现thymeleaf非严格检查。

#thymeleaf
spring.thymeleaf.encoding=UTF-8
spring.thymeleaf.suffix=.html
#默认严格检查
#spring.thymeleaf.mode=HTML5
#非严格检查
spring.thymeleaf.mode=LEGACYHTML5


本文地址:http://www.45fan.com/a/question/99642.html
Tags: 实现 模板 thymeleaf
编辑:路饭网
关于我们 | 联系我们 | 友情链接 | 网站地图 | Sitemap | App | 返回顶部