码迷,mamicode.com
首页 > 编程语言 > 详细

springboot的推荐模板引擎-Thymeleaf

时间:2019-05-15 11:14:52      阅读:162      评论:0      收藏:0      [点我收藏+]

标签:depend   star   http   html   let   ext   Servle   cat   The   

1)添加对themeleaf的支持的依赖

 <!--Thymeleaf-->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-thymeleaf</artifactId>
        </dependency>

2)在resources的templates目录下新建currentTime.html

技术图片

 

th:text的含义是把值显示在当前的标签内

字符串拼接采用双竖||符号就可以

3)修改application.properties,添加如下配置

#thymeleaf 配置
spring.thymeleaf.mode=HTML5
spring.thymeleaf.encoding=UTF-8
spring.thymeleaf.servlet.content-type=text/html
#缓存设置为false,立即生效
spring.thymeleaf.cache=false

 输入controller层的路径就可以看到页面效果

技术图片

 

springboot的推荐模板引擎-Thymeleaf

标签:depend   star   http   html   let   ext   Servle   cat   The   

原文地址:https://www.cnblogs.com/wutongshu-master/p/10868133.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!