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

参考:

thymeleaf官方指南

新一代Java模板引擎Thymeleaf

Thymeleaf基本知识

thymeleaf总结文章

Thymeleaf 模板的使用

thymeleaf 学习笔记

基本规则

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

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

表达式:

Simple expressions:(表达式语法)
Variable Expressions: ${...}:获取变量值;OGNL;
1)、获取对象的属性、调用方法
2)、使用内置的基本对象:
#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. ${session.foo}
3)、内置的一些工具对象:
#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). Selection Variable Expressions: *{...}:选择表达式:和${}在功能上是一样;
补充:配合 th:object="${session.user}:
<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> Message Expressions: #{...}:获取国际化内容
Link URL Expressions: @{...}:定义URL;
@{/order/process(execId=${execId},execType='FAST')}
Fragment Expressions: ~{...}:片段引用表达式
<div th:insert="~{commons :: main}">...</div> Literals(字面量)
Text literals: 'one text' , 'Another one!' ,…
Number literals: 0 , 34 , 3.0 , 12.3 ,…
Boolean literals: true , false
Null literal: null
Literal tokens: one , sometext , main ,…
Text operations:(文本操作)
String concatenation: +
Literal substitutions: |The name is ${name}|
Arithmetic operations:(数学运算)
Binary operators: + , - , * , / , %
Minus sign (unary operator): -
Boolean operations:(布尔运算)
Binary operators: and , or
Boolean negation (unary operator): ! , not
Comparisons and equality:(比较运算)
Comparators: > , < , >= , <= ( gt , lt , ge , le )
Equality operators: == , != ( eq , ne )
Conditional operators:条件运算(三元运算符)
If-then: (if) ? (then)
If-then-else: (if) ? (then) : (else)
Default: (value) ?: (defaultvalue)
Special tokens:
No-Operation: _

最新文章

  1. Android笔记:动画
  2. iOS开发 关于SEL的简单总结
  3. python 语料处理(从文件夹中读取文件夹中文件,分词,去停用词,去单个字)
  4. elasticsearch-cn-out-of-box
  5. Android 手机号码格式验证
  6. 关于c#中的Timer控件的简单用法
  7. C#程序设计基础——类、对象、方法
  8. li点击弹出序号
  9. I2C与EEPROM
  10. php日志
  11. ABAP语言实现 左移 &lt;&lt;、无符号右移 &gt;&gt;&gt; 位移操作
  12. rt-thread learning notes
  13. 【BZOJ】3295: [Cqoi2011]动态逆序对
  14. learn python the hard way习题31~40总结以及列表的扩展知识
  15. 05 爬虫之scrapy
  16. spring整合mybatis、hibernate、logback配置
  17. task 定时设置
  18. attachEvent方法绑定事件
  19. git使用分支与tag
  20. Unity----Scene加载问题

热门文章

  1. Oracle存储过程----存储过程执行简单的增删改查
  2. php/js将 CST时间转成格式化时间
  3. Linux使用mount挂载samba共享文件夹
  4. AWS ec2的ubuntu14.04上安装git服务
  5. 出现 HTTP Status 500 - Servlet.init() for servlet springmvc threw exception 异常
  6. codeforces A. Zoning Restrictions Again
  7. ASP.NET Core Web API 控制器与方法返回输出
  8. css动画 自动打字,让你的文字飞舞起来
  9. 第二十一篇 Linux中的环境变量简单介绍
  10. HTML入门归纳--JavaScript