首页 > 编程语言 > 详细

spring boot-9.对springMVC的支持

时间:2018-08-17 15:19:38      阅读:138      评论:0      收藏:0      [点我收藏+]

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的支持

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

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