您的位置:首页 > 编程语言 > Java开发

Spring boot使用Thymeleaf模板的时候标签未关闭报错解决

2018-01-17 17:32 429 查看

问题

在spring boot 中,推荐使用thymeleaf来做前端模版引擎,但是会报标签未关闭:

org.thymeleaf.exceptions.TemplateInputException: Exception parsing document: template="login"


比如:
<link rel="stylesheet" type="text/css" href="../css/bootstrap.css" >
必须改成
<link rel="stylesheet" type="text/css" href="../css/bootstrap.css" />


如果一个一个改的话又很麻烦。。。ヽ(#`Д´)ノ

解决

1.在
pom.xml
中引入依赖:

<dependencies>
<!--thymeleaf-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
<dependency>
<groupId>net.sourceforge.nekohtml</groupId>
<artifactId>nekohtml</artifactId>
<version>1.9.22</version>
</dependency>
</dependencies>


2.在
application-dev.yml
中设置:

spring:
thymeleaf:
cache: false
mode: LEGACYHTML5

server:
port: 8081
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: