表达式

查看文档

Variable Expressions: ${...}
Selection Variable Expressions: *{...}
Message Expressions: #{...}
Link URL Expressions: @{...}
Fragment Expressions: ~{...}

${…}

获取变量值,底层是OGNL表达式
获取对象的属性、调用方法

调用对象属性

${person.father.name}
${person['father']['name']}

Map获取

${countriesByCode.ES}
${personsByName['Stephen Zucchini'].age}

数组获取

${personsArray[0].name}

调用方法,可以传参数

${person.createCompleteName()}
${person.createCompleteNameWithSeparator('-')}


使用内置的基本对象

#ctx : the context object.
#vars: the context variables.
#locale : the context locale.
#request : (only in Web Contexts) the HttpServletRequest object.
#response : (only in Web Contexts) the HttpServletResponse object.
#session : (only in Web Contexts) the HttpSession object.
#servletContext : (only in Web Contexts) the ServletContext object.

使用方式

内置的一些工具对象

#execInfo : information about the template being processed.
#messages : methods for obtaining externalized messages inside variables expressions, in the same way as they
would be obtained using #{…} syntax.
#uris : methods for escaping parts of URLs/URIs
#conversions : methods for executing the configured conversion service (if any).
#dates : methods for java.util.Date objects: formatting, component extraction, etc.
#calendars : analogous to #dates , but for java.util.Calendar objects.
#numbers : methods for formatting numeric objects.
#strings : methods for String objects: contains, startsWith, prepending/appending, etc.
#objects : methods for objects in general.
#bools : methods for boolean evaluation.
#arrays : methods for arrays.
#lists : methods for lists.
#sets : methods for sets.
#maps : methods for maps.
#aggregates : methods for creating aggregates on arrays or collections.
#ids : methods for dealing with id attributes that might be repeated (for example, as a result of an iteration).

使用方式

*{…}

选择表达式
与${}在功能上是一样,添加了一个补充功能
配合th:object进行使用

*号,表示当前div中,获取的对象Object
直接获取对象的属性即可

<div th:object="${session.user}"><p>Name: <span th:text="*{firstName}">Sebastian</span>.</p><p>Surname: <span th:text="*{lastName}">Pepper</span>.</p><p>Nationality: <span th:text="*{nationality}">Saturn</span>.</p>
</div>

#{…}

获取国际化内容

@{…}

定义URL

~{…}

片段引用表达式

Thymeleaf表达式相关推荐

  1. thymeleaf表达式优先级及表达式简单说明

    thymeleaf表达式优先级: 表达式简单说明: th:insert 片段包含 th:replace 片段替换 th:each 遍历 th:if 条件判断 th:unless th:switch t ...

  2. idea中html的红波浪线是什么意思,IDEA中thymeleaf 表达式报红波浪线

    一,场景再现 最近在做一个SpringBoot项目,于是自然就接触到了thymeleaf .但是在开发中,遇到一个很奇怪的现象. 从上面图片我们看到,我们在html页面利用thymeleaf表达式取值 ...

  3. 解决idea thymeleaf表达式模板报红波浪线

    我的问题 解决方法:把下面的代码段直接复制粘贴(注释不能删掉) <!DOCTYPE html> <!--解决idea thymeleaf 表达式模板报红波浪线--> <! ...

  4. 解决idea thymeleaf 表达式模板报红波浪线

    解决方法:直接在后加加两行代码 <!DOCTYPE html> <!--解决idea thymeleaf 表达式模板报红波浪线--> <!--suppress ALL - ...

  5. Thymeleaf 标准表达式语法详解

    Thymeleaf 表达式汇总 首先先加入命名空间 <html xmlns:th="http://www.thymeleaf.org"> 编号 属性 描述 示例 1 $ ...

  6. SpringBoot中使用Thymeleaf常用功能(一):表达式访问数据

    环境搭建: 创建一个Maven项目,按照Maven项目的规范,在src/main/下新建一个名为resources的文件夹,并在下面新建static和templates文件夹. ①  修改pom.xm ...

  7. Thymeleaf 语法快速入门

    1.简介 官方网站:https://www.thymeleaf.org Thymeleaf是用来开发Web和独立环境项目的现代服务器端Java模板引擎. Thymeleaf的主要目标是为您的开发工作流 ...

  8. thymeleaf语法介绍

    Thymeleaf简介 官方网站:https://www.thymeleaf.org/index.html Thymeleaf是用来开发Web和独立环境项目的现代服务器端Java模板引擎. Thyme ...

  9. Thymeleaf的入门(一)

    引自:http://how2j.cn/k/springboot/springboot-thymeleat/1735.html Thyemeleaf初步使用 Thymeleaf的引入(内容填充) 1.在 ...

最新文章

  1. 微型计算机启天A5000-B124说明,微型计算机原理及应用知识点总结
  2. java控制io_Java-IO操作
  3. Android开发之Socket通信的方法
  4. jboss-5.1.0_JBoss AS 7.1.0.Final“ Thunder”发布-Java EE 6 Full Profile认证!
  5. mysql 主从热备份 5.6 参数_MySQL主从热备份
  6. P2P穿透四种NAT类型
  7. 转载:什么是良好的Verilog代码风格?(作者KellenWang)
  8. C#的6种常用集合类大比拼
  9. cisco2811 一对一IP地址映射
  10. ShadowGun 图形技术分析
  11. c盘里appdata是什么文件夹?
  12. 伽罗华域(Galois Field,GF,有限域)乘法运算
  13. Java黑皮书编程练习题6.08(摄氏度和华氏度之间的转换)
  14. jenkins4-jenkins源码管理无法连接仓库:Command git ls-remote -h --
  15. Segment Routing
  16. 万彩办公大师多页PDF文档去掉空白部分合并到同一页
  17. Mark(转载)古人读书十二法
  18. 进制的转换 如六进制
  19. Gate Developer 软件快捷键
  20. MMU简单处理TLB例外

热门文章

  1. 【angular5项目积累总结】列表多选样式框(1)
  2. ecshop php5.4以上版本错误之preg_replace 替换成 preg_replace_callback
  3. 收藏开发人员常去网站
  4. ArcGIS Server 部署与配置
  5. _stdcall调用
  6. Singleton Pattern(单例模式)
  7. EOS账户系统(1)场景
  8. 《图解密码技术》分组密码(5) 输出反馈OFB模式
  9. 4.11-固件映像包 (FIP)
  10. MTK平台的启动流程(secureboot)