详细内容见:Thymeleaf Tutorial 中文翻译,中文文档

参考:

thymeleaf官方指南

新一代Java模板引擎Thymeleaf

Thymeleaf基本知识

thymeleaf总结文章

Thymeleaf 模板的使用

thymeleaf 学习笔记

基本规则

th:text;改变当前元素里面的文本内容;

th:任意html属性;来替换原生属性的值

表达式:

  1. Simple expressions:(表达式语法)
  2. Variable Expressions: ${...}:获取变量值;OGNL
  3. 1)、获取对象的属性、调用方法
  4. 2)、使用内置的基本对象:
  5. #ctx : the context object.
  6. #vars: the context variables.
  7. #locale : the context locale.
  8. #request : (only in Web Contexts) the HttpServletRequest object.
  9. #response : (only in Web Contexts) the HttpServletResponse object.
  10. #session : (only in Web Contexts) the HttpSession object.
  11. #servletContext : (only in Web Contexts) the ServletContext object.
  12. ${session.foo}
  13. 3)、内置的一些工具对象:
  14. #execInfo : information about the template being processed.
  15. #messages : methods for obtaining externalized messages inside variables expressions, in the same way as they would be obtained using #{…} syntax.
  16. #uris : methods for escaping parts of URLs/URIs
  17. #conversions : methods for executing the configured conversion service (if any).
  18. #dates : methods for java.util.Date objects: formatting, component extraction, etc.
  19. #calendars : analogous to #dates , but for java.util.Calendar objects.
  20. #numbers : methods for formatting numeric objects.
  21. #strings : methods for String objects: contains, startsWith, prepending/appending, etc.
  22. #objects : methods for objects in general.
  23. #bools : methods for boolean evaluation.
  24. #arrays : methods for arrays.
  25. #lists : methods for lists.
  26. #sets : methods for sets.
  27. #maps : methods for maps.
  28. #aggregates : methods for creating aggregates on arrays or collections.
  29. #ids : methods for dealing with id attributes that might be repeated (for example, as a result of an iteration).
  30. Selection Variable Expressions: *{...}:选择表达式:和${}在功能上是一样;
  31. 补充:配合 th:object="${session.user}:
  32. <div th:object="${session.user}">
  33. <p>Name: <span th:text="*{firstName}">Sebastian</span>.</p>
  34. <p>Surname: <span th:text="*{lastName}">Pepper</span>.</p>
  35. <p>Nationality: <span th:text="*{nationality}">Saturn</span>.</p>
  36. </div>
  37. Message Expressions: #{...}:获取国际化内容
  38. Link URL Expressions: @{...}:定义URL;
  39. @{/order/process(execId=${execId},execType='FAST')}
  40. Fragment Expressions: ~{...}:片段引用表达式
  41. <div th:insert="~{commons :: main}">...</div>
  42. Literals(字面量)
  43. Text literals: 'one text' , 'Another one!' ,…
  44. Number literals: 0 , 34 , 3.0 , 12.3 ,…
  45. Boolean literals: true , false
  46. Null literal: null
  47. Literal tokens: one , sometext , main ,…
  48. Text operations:(文本操作)
  49. String concatenation: +
  50. Literal substitutions: |The name is ${name}|
  51. Arithmetic operations:(数学运算)
  52. Binary operators: + , - , * , / , %
  53. Minus sign (unary operator): -
  54. Boolean operations:(布尔运算)
  55. Binary operators: and , or
  56. Boolean negation (unary operator): ! , not
  57. Comparisons and equality:(比较运算)
  58. Comparators: > , < , >= , <= ( gt , lt , ge , le )
  59. Equality operators: == , != ( eq , ne )
  60. Conditional operators:条件运算(三元运算符)
  61. If-then: (if) ? (then)
  62. If-then-else: (if) ? (then) : (else)
  63. Default: (value) ?: (defaultvalue)
  64. Special tokens:
  65. No-Operation: _

Springboot学习:Thymeleaf 语法基础的更多相关文章

  1. 【原】无脑操作:IDEA + maven + Shiro + SpringBoot + JPA + Thymeleaf实现基础授权权限

    上一篇<[原]无脑操作:IDEA + maven + Shiro + SpringBoot + JPA + Thymeleaf实现基础认证权限>介绍了实现Shiro的基础认证.本篇谈谈实现 ...

  2. 【原】无脑操作:IDEA + maven + Shiro + SpringBoot + JPA + Thymeleaf实现基础认证权限

    开发环境搭建参见<[原]无脑操作:IDEA + maven + SpringBoot + JPA + Thymeleaf实现CRUD及分页> 需求: ① 除了登录页面,在地址栏直接访问其他 ...

  3. 学习mysql语法--基础篇(一)

      前  言  mysql  mysql语法--本篇学习都是通过使用Navicat Premium(数据库管理工具),连接mysql数据. 本篇学习主要有两个部分:    一.创建用户,创建数据库,给 ...

  4. 学习mysql语法--基础篇(二)

      前  言  mysql  mysql语法--本篇学习都是通过使用Navicat Premium(数据库管理工具),连接mysql数据. 本篇学习主要有两个部分: [SQL语句的组成]   DML ...

  5. 2019-10-10:渗透测试,基础学习,mysql语法基础,笔记

    mysql常用命令mysql -u用户名 -p,登录方式也称为,二进制方式exit 退出mysql 查看mysql版本select version(); 查看mysql所有数据库show dateba ...

  6. 从.Net到Java学习第九篇——SpringBoot下Thymeleaf

    从.Net到Java学习系列目录 Thymeleaf概述 Thymeleaf 是一个流行的模板引擎,该模板引擎采用java语言开发.模板引擎是一个技术名称,是跨领域平台的概念,在java语言体系下有模 ...

  7. 从.Net到Java学习第六篇——SpringBoot+mongodb&Thymeleaf&模型验证

    SpringBoot系列目录 SpringBoot整合mongodb MongoDB 是一个介于关系数据库和非关系数据库之间的产品,是非关系数据库当中功能最丰富,最像关系数据库的.如果你没用过Mong ...

  8. Groovy语言学习--语法基础(5)

    至此groovy语言学习-语法基础就结束了,新的工作已经安排下来,要干活了. 对groovy了解到一定程度之后就可以在java项目中对其进行引入了.为此新建了一个微型的项目,个人觉得千言万语不如代码实 ...

  9. Groovy语言学习--语法基础(1)

    2018年11月末,从上家公司离职后进入现在的公司.进入项目以来,发现项目中有很多groovy脚本,以前没接触过groovy,抽时间系统地学一下,也方便后期项目的开发和维护. groovy和java的 ...

随机推荐

  1. c#解析json字符串处理

    本文链接:https://blog.csdn.net/sajiazaici/article/details/77647625本文是全网第二简单的方法,因为我女票也发了一篇博客说是全网最简单的方法,我不 ...

  2. MySQL数据库、数据表和字段字符集查询、修改和配置

    一.设置编码 LINUX  修改vi/etc/my.cnf WINDOWS my.ini 在[client]下添加    default-character-set=utf8 在[mysqld]下添加 ...

  3. linux下grep分析apache日志的命令集合

    https://my.oschina.net/hmc0316/blog/112004 实例:月份英文简写英文全称一月Jan.January二月Feb.February三月Mar.March四月Apr. ...

  4. CentOS根目录下各目录介绍

    bin :存放普通用户可执行的指令,即使在单用户模式下也能够执行处理 boot :开机引导目录,包括Linux内核文件与开机所需要的文件 dev :设备目录,所有的硬件设备及周边均放置在这个设备目录中 ...

  5. spring cloud config 连接GitHub访问 报错 Cannot clone or checkout repository

    原因是建立仓库的时候将仓库私有化了,将仓库公有 或者 设置账号密码即可!

  6. 三分钟快速上手TensorFlow 2.0 (上)——前置基础、模型建立与可视化

    本文学习笔记参照来源:https://tf.wiki/zh/basic/basic.html 学习笔记类似提纲,具体细节参照上文链接 一些前置的基础 随机数 tf.random uniform(sha ...

  7. Object的rest和spread方法

    //将多个对象合并到一个对象里 const input = { a: 1, b: 2 } const test = { d: 5 } const output = { ...input, ...tes ...

  8. IntelliJ IDEA 2017.3尚硅谷-----修改当前主题字体、字体大小、行间距、控制台、注释

  9. PAT甲级题解分类byZlc

    专题一  字符串处理 A1001 Format(20) #include<cstdio> int main () { ]; int a,b,sum; scanf ("%d %d& ...

  10. Sass&Scss入门 选择器 混合器 导入 条件判断 迭代

    Sass 基于ruby的一种将脚本解析成CSS的脚本语言.也可以说是一种预处理语言. Sass在css的语法基础上增加了变量.嵌套.混合.继承.导入等高级功能. 使用Sass与Sass样式库(如com ...