thymeleaf中的Literals
Literals即为文字
一.Text literals:文本文字
文本文字只是字符串指定的单引号之间。他们可以包含任何字符,但你应避免任何单引号里面\ '
<p>
Now you are looking at a <span th:text="'working web application'">template file</span>.
</p>
如果是带空格什么的不连贯的一段话,例如working web application,必须要用单引号引起来才能被解析,如果是如下则不能被解析,会出现错误:
<p>
Now you are looking at a <span th:text="working web application">template file</span>.
</p>
如果是连贯的不分开的如下是正确被解析的:
<p>
Now you are looking at a <span th:text="workingwebapplication">template file</span>.
</p>
二:文字数量
数字文字看起来像:数字。
例子:
<p>The year is <span th:text="2014">1492</span>.</p>
<p>In two years, it will be <span th:text="2013 + 2">1494</span>.</p>
显示结果:
The year is 2014
In two years, it will be 2016
三.布尔型常量
布尔常量true和false。例如:
<div th:if="${user.isAdmin()} == false"> 如果是false我显示</div>
注意,在上面的例子中,==false写在括号外,因此Thymeleaf本身照顾它。如果它是写在括号内,这将是OGNL/SpringEL引擎展示出:
<div th:if="${user.isAdmin() == false}"> 如果是false我显示</div>
四.空的文字
<div th:if="${variable.something} == null">如果为空我显示</div>
五.附加的文本
文本,无论他们是文字或评估的结果变量或消息表达式,可以很容易地添加使用+运算符:
th:text="'The name of the user is ' + ${user.name}"
六.文字替换:
文字替换允许简单的格式化字符串包含值的变量而不需要附加的文字……‘+’……”。这些替换必须包围竖线(|),如:
<span th:text="|Welcome to our application, ${user.name}!|">
等同于:
<span th:text="'Welcome to our application,'+ ${user.name}+'!'">
文字替换可以结合其他类型的表达式:
<span th:text="${onevar} + ' ' + |${twovar}, ${threevar}|">
算术运算:
<p th:with="isEven=(${user.count} % 2 == 0)">显示</p>
thymeleaf中的Literals的更多相关文章
- thymeleaf中的日期格式化
本篇介绍些thymeleaf中的日期格式化的方法: 1.用#dates.format来解决: <span th:text="${#dates.format(user.date, 'yy ...
- thymeleaf中th:attr用法以及相关的thymeleaf基本表达式
额,有人写的很好,我直接搬了 thymeleaf中th:attr用法 1.写死的单个属性值添加 th:attr="class=btn" 2.写死的多个属性值添加 th:attr=& ...
- thymeleaf中double/float格式化,四舍五入显示两位小数
private Float balance; 代码: <span class="A124_balance_num" th:text="${#numbers.form ...
- thymeleaf中分类信息使用不同的样式
需求: 相关class类名:S224_on_point url:/notification/list url:/notification/list?type=2 thymeleaf代码如下: < ...
- springboot Thymeleaf中格式化jsr310新日期时间类(LocalDateTime,LocalDate)--thymeleaf格式化LocalDateTime,LocalDate等JDK8新时间类
依赖maven包 <dependency> <groupId>org.thymeleaf.extras</groupId> <artifactId>th ...
- Thymeleaf 中如何实现including
Problem:Jsp中有including,Thymeleaf中有无类似的语法? Solution:有,Themeleaf中提供同样功能的标签是 th:fragment="blockNam ...
- thymeleaf中的内联[ [ ] ]
一.文本内联 [[…]]之间的表达式在Thymeleaf被认为是内联表达式,在其中您可以使用任何类型的表达式,也会有效th:text属性. <p>Hello, [[${session.us ...
- thymeleaf中的模板布局
一.包括模板片段: 1:定义和引用片段,我们经常会想要包含在模板片段来自其他模板.常见的用途是页脚.标题.菜单…; 为了做到这一点,Thymeleaf需要我们定义包含可用的片段,我们可以通过使用th: ...
- 12. thymeleaf中资源相对路径的解决
把博客部署到tomcat上后才发现因之前资源和链接的地址都是使用的相对路径,这样一来在tomcat上就各种找不到资源.从网上看了几种解决方式都挺麻烦的,且不是适配的,所以我根据thymeleaf的规则 ...
随机推荐
- bzoj1499: [NOI2005]瑰丽华尔兹
dp. 首先我们可以看到每个时间段只能往一个方向转移最多t步(t为时间段的长度),所以我们可以按时间段dp.因为这个前后值互不影响,也不用占用这一维空间就可以省去. 然后每个时间段内是一列一列(行) ...
- QWidget、QDialog、QMainWindow的异同点
简述 在分享所有基础知识之前,很有必要在这里介绍下常用的窗口 - QWidget.QDialog.QMainWindow. QWidget继承于QObject和QPaintDevice,QDialog ...
- 为什么会出现ADB rejected shell command
出现这个问题,是由于在运行过程中,android emulator 没有打开,可以在run configurations--target- automatic-设置自己的android-version ...
- LeetCode: 3SumClosest
Title : Given an array S of n integers, find three integers in S such that the sum is closest to a g ...
- BMP图像格式
BMP(全称Bitmap)是Window操作系统中的标准图像文件格式,可以分成两类:设备相关位图(DDB)和设备无关位图(DIB),使用非常广.它采用位映射存储格式,除了图像深度可选以外,不采用其他任 ...
- ASP.NET 经典60道面试题
转:http://bbs.chinaunix.net/thread-4065577-1-1.html ASP.NET 经典60道面试题 1. 简述 private. protected. public ...
- WEXT driver的执行过程实现(iwpriv部分/softapcontroller)
之前在看wifi driver源代码时一直有一个疑惑就是net dev的wireless_handlers中(WEXT类型的接口)提供两个iw_handler接口,怎么知道上层是调用的是private ...
- [Everyday Mathematics]20150108
设 $f$ 在 $(a,b)$ 上 $n+1$ 次可导, 且 $$\bex \ln\frac{f(b)+f'(b)+\cdots+f^{(n)}(b)}{f(a)+f'(a)+\cdots+f^{(n ...
- Linux+Apache+Tomcat集群配置
参考: http://blog.csdn.net/bluishglc/article/details/6867358# http://andashu.blog.51cto.com/8673810/13 ...
- 使用DDMS测试安卓手机APP的性能(android)
安装/配置: 通过另外一个工具也可以测试手机客户端APP的性能,这就是android开发包中的DDMS工具(Dalvik Debug Monitor Service),先来说一下android开发包的 ...