您的位置:首页 > Web前端 > HTML5

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

2018-02-24 14:48 441 查看

一、概述

最近在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
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息