首页 > 编程语言 > 详细

springboot之thymeleaf

时间:2019-10-29 14:14:55      阅读:86      评论:0      收藏:0      [点我收藏+]

如果想在springboot中使用thymeleaf的话,需要两步:

  1. 在pom.xml文件中添加如下依赖:

# pom.xml
<!-- 用于解析html文件 -->
<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>

  2. 在application.properties配置文件中添加如下配置:

#  application.properties

#配置解析html
spring.thymeleaf.prefix=/WEB-INF/content/
spring.thymeleaf.suffix=.html
spring.thymeleaf.mode=HTML5
spring.thymeleaf.encoding=UTF-8
spring.thymeleaf.content-type=text/html
#开发时设置为false,否则看不到实时的页面
spring.thymeleaf.cache=false

  其中 prefix 是你的html文件的所在位置前缀,跟你的文件存放位置而改变。

  需要注意的是  thymeleaf  解析的html中的内容,标签必须是成对出现的,不然会报错导致无法运行,例如:<meta charset="UTF-8"></meta>

springboot之thymeleaf

原文:https://www.cnblogs.com/wangyusu/p/11758357.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!