当前位置:网站首页>Thymeleaf common functions
Thymeleaf common functions
2022-07-05 14:17:00 【fengyehongWorld】
Catalog
- One . #dates
- Two . #numbers
- 3、 ... and . #strings
- `#strings.toString`
- `#strings.isEmpty`
- `#strings.defaultString`
- `#strings.contains`
- `#strings.containsIgnoreCase`
- `#strings.startsWith`
- `#strings.endsWith`
- `#strings.indexOf`
- `#strings.substring`
- `#strings.replace`
- `#strings.prepend`
- `#strings.append`
- `#strings.toUpperCase`
- `#strings.length`
- `#strings.trim`
- `#strings.abbreviate`
- Four . #objects
- 5、 ... and . #bools
One . #dates
Processing date data . Generate , transformation , Get the specific number of days and years of the date .
#dates.createNow
Generate current date ( amount to Java Of new Date())
<span th:text="${#dates.createNow()}"></span>
<!-- Results page -->
<span>Sun May 16 09:38:33 CST 2021</span>
#dates.create
- Construct a date
<span th:text="${#dates.create('2019','05','31','10','18')}"></span>
<!-- Results page -->
<span>Fri May 31 10:18:00 CST 2019</span>
#dates.format
- Format the date
- When formatting the date , The date must be
new Date()
type , Cannot be string date type , Otherwise, an error will be reported .
<span th:text="*{#dates.format(#dates.createNow())}"></span>
<!-- Results page -->
<span>2021 year 5 month 16 Japan In the morning 09 when 40 branch 46 second </span>
- Format the date in the specified format
<span th:text="*{#dates.format(#dates.createNow(), 'yyyy/MM/dd HH:mm')}"></span>
<!-- Results page -->
<span>2021/05/16 09:43</span>
<span th:text="*{#dates.format(#dates.createNow(), 'yyyy year MM month dd Japan HH:mm')}"></span>
<!-- Results page -->
<span>2021 year 05 month 16 Japan 09:43</span>
#dates.year
- Year of acquisition
<span th:text="*{#dates.year(#dates.createNow())}"></span>
<!-- Results page -->
<span>2021</span>
#dates.month
- Get month ( Use inline )
<span>[[*{#dates.month(#dates.createNow())}]]</span>
<!-- Results page -->
<span>5</span>
#dates.monthName
<span th:text="*{#dates.monthName(#dates.createNow())}"></span>
<!-- Results page -->
<span> May </span>
#dates.monthNameShort
<span th:text="*{#dates.monthNameShort(#dates.createNow())}"></span>
<!-- Results page -->
<span> May </span>
#dates.day
- Get date
<span th:text="*{#dates.day(#dates.createNow())}"></span>
<!-- Results page -->
<span>30</span>
#dates.dayOfWeek
Get the day of the week ( The situation in foreign countries , Sunday is the first day of the week )
<span th:text="*{#dates.dayOfWeek(#dates.createNow())}"></span>
<!-- Results page -->
<span>1</span>
#dates.dayOfWeekName
<span th:text="*{#dates.dayOfWeekName(#dates.createNow())}"></span>
<!-- Results page -->
<span> Sunday </span>
#dates.dayOfWeekNameShort
<span th:text="*{#dates.dayOfWeekNameShort(#dates.createNow())}"></span>
<!-- Results page -->
<span> Sunday </span>
#dates.hour
- Get the current hour
<span th:text="*{#dates.hour(#dates.createNow())}"></span>
<!-- Results page -->
<span>10</span>
#dates.minute
- Get the current minute
<span th:text="*{#dates.minute(#dates.createNow())}"></span>
<!-- Results page -->
<span>6</span>
#dates.second
- Get the current second
<span th:text="*{#dates.second(#dates.createNow())}"></span>
<!-- Results page -->
<span>12</span>
#dates.millisecond
- Gets the current number of milliseconds
<span th:text="*{#dates.millisecond(#dates.createNow())}"></span>
<!-- Results page -->
<span>221</span>
Two . #numbers
Handle the conversion of digital data
- Make up for numbers that are not enough 0(formatInteger)
- Set thousands separator (formatInteger)
- Exact decimal point (formatDecimal)
- Set the percent sign (formatPercent)
- Generating arrays (sequence)
#numbers.formatInteger
- Make up for numbers that are not enough 0
<p th:text="${#numbers.formatInteger('123',4)}"></p> // 0123
<p th:text="${#numbers.formatInteger('123',2)}"></p> // 123
- Set thousands separator
.
<p th:text="${#numbers.formatInteger('1000',2,'POINT')}"></p> // 1.000
<p th:text="${#numbers.formatInteger('1000',6,'POINT')}"></p> // 001.000
<p th:text="${#numbers.formatInteger('1000',7,'POINT')}"></p> // 0.001.000
Set thousands separator ,
<p th:text="${#numbers.formatInteger('1000', 2, 'COMMA')}"></p> // 1,000
<div th:text="*{#numbers.formatInteger('1000', 0, 'COMMA')}"></div> // 1,000
Set the thousand separator to blank
<p th:text="${#numbers.formatInteger('1000', 2, 'WHITESPACE')}"></p> // 1 000
#numbers.formatDecimal
Exact decimal point
<p th:text="${#numbers.formatDecimal('10.123', 3, 2)}"></p> // 010.12
#numbers.formatCurrency
Money display symbol
<p th:text="${#numbers.formatCurrency('1000')}"></p> // ¥1,000.00
#numbers.formatPercent
Percentage operation
<p th:text="${#numbers.formatPercent('0.2',2, 4)}"></p> // 20.0000%
<p th:text="${#numbers.formatPercent('0.2',3, 2)}"></p> // 020.00%
3、 ... and . #strings
- String conversion (toString)
- Check if the string is empty (isEmpty)
- String is an empty replace operation (defaultString)
- Check if the string contains a string (contains containsIgnoreCase)
- Check whether the string starts or ends with a fragment (startsWith endsWith)
- Intercept (substring substringAfter)
- Replace (replace)
- Additional (prepend append)
- Change case (toUpperCase toLowerCase)
- Split and combine strings (arrayJoin arraySplit)
- Go to space (trim)
- Abbreviated text (abbreviate)
- String connection (concat)
#strings.toString
// java Code
Object object = "123";
<p th:text="${#strings.toString(object)}"></p>
<p>123</p>
#strings.isEmpty
String name = null;
<p th:text="${#strings.isEmpty(name)}"></p>
<p>true</p>
#strings.defaultString
String text = null;
String text1 = "123";
<p th:text="${#strings.defaultString(text,' The value is null')}"></p>
<p> The value is null</p>
<p th:text="${#strings.defaultString(text1,' The value is null')}"></p>
<p>123</p>
#strings.contains
<p th:text="${#strings.contains('abcez','ez')}"></p>
<p>true</p>
#strings.containsIgnoreCase
<p th:text="${#strings.containsIgnoreCase('abcEZ','ez')}"></p>
<p>true</p>
#strings.startsWith
<p th:text="${#strings.startsWith('Donabcez','Don')}"></p>
<p>true</p>
#strings.endsWith
<p th:text="${#strings.endsWith('Donabcezn','n')}"></p>
<p>true</p>
#strings.indexOf
<p th:text="${#strings.indexOf('abcefg','e')}"></p>
<p>3</p>
#strings.substring
<p th:text="${#strings.substring('abcefg',3,5)}"></p>
<p>ef</p>
#strings.replace
<p th:text="${#strings.replace('lasabce','las','ler')}"></p>
<p>lerabce</p>
#strings.prepend
<p th:text="${#strings.prepend('abc','012')}"></p>
<p>012abc</p>
#strings.append
<p th:text="${#strings.append('abc','456')}"></p>
<p>abc456</p>
#strings.toUpperCase
<p th:text="${#strings.toLowerCase('ABC')}"></p>
<p>abc</p>
#strings.length
<p th:text="${#strings.length('abc')}"></p>
<p>3</p>
#strings.trim
<p th:text="${#strings.trim(' abc ')}"></p>
<p>abc</p>
#strings.abbreviate
<p th:text="${#strings.abbreviate('12345678910',10)}"></p>
<p>1234567...</p>
Four . #objects
#objects.nullSafe
<p th:text="${#objects.nullSafe(null,' The object of null')}"></p>
<p> The object of null</p>
5、 ... and . #bools
#bools.isTrue
<p th:text="${#bools.isTrue(true)} "></p>
<p>true</p>
<p th:text="${#bools.isTrue(false)} "></p>
<p>false</p>
<p th:text="${#bools.isTrue('on')} "></p>
<p>true</p>
<p th:text="${#bools.isTrue('off')} "></p>
<p>false</p>
<p th:text="${#bools.isTrue('true')} "></p>
<p>true</p>
<p th:text="${#bools.isTrue('false')} "></p>
<p>false</p>
<p th:text="${#bools.isTrue(1)} "></p>
<p>true</p>
<p th:text="${#bools.isTrue(0)} "></p>
<p>false</p>
边栏推荐
猜你喜欢
TiFlash 面向编译器的自动向量化加速
Simple process of penetration test
LeetCode_ 2 (add two numbers)
快消品行业SaaS多租户解决方案,构建全产业链数字化营销竞争力
Scenario based technology architecture process based on tidb - Theory
TDengine 社区问题双周精选 | 第三期
Financial one account Hong Kong listed: market value of 6.3 billion HK $Ye wangchun said to be Keeping true and true, long - term work
基于 TiDB 场景式技术架构过程 - 理论篇
神经网络物联网未来发展趋势怎么样
Make the seckill Carnival more leisurely: the database behind the promotion (Part 2)
随机推荐
做自媒體視頻二次剪輯,怎樣剪輯不算侵權
展现强大。这样手机就不会难前进
R语言ggplot2可视化:可视化折线图、使用theme函数中的legend.position参数自定义图例的位置
R语言ggplot2可视化:gganimate包基于transition_time函数创建动态散点图动画(gif)、使用shadow_mark函数为动画添加静态散点图作为动画背景
R语言ggplot2可视化:使用ggplot2可视化散点图、使用labs参数自定义X轴的轴标签文本(customize X axis labels)
用“新”字来吸引好奇的人群
区间 - 左闭右开
R语言使用MASS包的polr函数构建有序多分类logistic回归模型、使用coef函数获取模型中每个变量(自变量改变一个单位)对应的对数优势比(log odds ratio)
R语言使用原生包(基础导入包、graphics)中的boxplot函数可视化箱图(box plot)
SAS接口有什么优势特点
Faire un clip vidéo auto - média deux fois, comment clip n'est pas considéré comme une infraction
关于Apache Mesos的一些想法
C - Divisors of the Divisors of An Integer Gym - 102040C
upload (1-6)
分享 20 个稀奇古怪的 JS 表达式,看看你能答对多少
POI set the data format of the column (valid)
How to call the function mode of one hand and one machine
金融壹賬通香港上市:市值63億港元 葉望春稱守正篤實,久久為功
R语言ggplot2可视化密度图:按照分组可视化密度图、自定义配置geom_density函数中的alpha参数设置图像透明度(防止多条密度曲线互相遮挡)
非技术部门,如何参与 DevOps?