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

spring boot-9.对springMVC的支持

时间:2018-08-17 15:29:53      阅读:125      评论:0      收藏:0      [点我收藏+]

标签:pen   定义   自动配置   字符   cti   frame   org   判断   star   

1.thymeleaf

spring boot 推荐的模板引擎是thymeleaf。spring boot 的自动配置已经默认配置好了themleaf,只要导入themleaf的Starter就可以了。

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

</dependency>

为了使用themleaf的高级特性,建议将themleaf版本切换至3.0以上

<properties>
        <thymeleaf.version>3.0.9.RELEASE</thymeleaf.version>
        <thymeleaf-layout-dialect.version>2.1.1</thymeleaf-layout-dialect.version>
</properties>

themleaf 可以用th:开头的所有标签去替换原生html的相应标签,主要的语法有以下几个点:

(1)${...} 取变量的值,类似于OGNL

(2)#{...}:获取国际化内容

(3)@{...}:定义URL

(4)~{...}:片段引用表达式

(5)*{...}:选择变量表达式,功能和${}类似

themleaf 同时支持字符串操作,数学计算,比较,条件判断,还内置了很多工具方法,如可以进行日期格式化的方法${#dates.format(date)}

 

spring boot-9.对springMVC的支持

标签:pen   定义   自动配置   字符   cti   frame   org   判断   star   

原文地址:https://www.cnblogs.com/li-zhi-long/p/9493442.html

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