当前位置:网站首页>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>
边栏推荐
- 根据CronSequenceGenerator计算cron表达式的时间
- R语言ggplot2可视化条形图:通过双色渐变配色颜色主题可视化条形图、为每个条形添加标签文本(geom_text函数)
- C - Divisors of the Divisors of An Integer Gym - 102040C
- Make the seckill Carnival more leisurely: the database behind the promotion (Part 2)
- 01 、Solr7.3.1 在Win10平台下使用jetty的部署及配置
- 3W原则[通俗易懂]
- What is the future development trend of neural network Internet of things
- R language dplyr package select function, group_ By function, mutate function and cumsum function calculate the cumulative value of the specified numerical variable in the dataframe grouping data and
- Tidb DM alarm DM_ sync_ process_ exists_ with_ Error troubleshooting
- Detailed explanation of SSH password free login
猜你喜欢

Kunlun Taike rushes to the scientific innovation board: the annual revenue is 130million, and it plans to raise 500million. CETC Taiji holds 40% of the shares

Sqllab 1-6 exercise

快消品行业SaaS多租户解决方案,构建全产业链数字化营销竞争力

Tdengine biweekly selection of community issues | phase III

Tidb DM alarm DM_ sync_ process_ exists_ with_ Error troubleshooting

Zhizhen new energy rushes to the scientific innovation board: the annual revenue is 220million, and SAIC venture capital is the shareholder

Principle and performance analysis of lepton lossless compression

Thymeleaf th:with局部变量的使用

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

TiFlash 源码解读(四) | TiFlash DDL 模块设计及实现分析
随机推荐
Faire un clip vidéo auto - média deux fois, comment clip n'est pas considéré comme une infraction
Hongmeng fourth training
R language ggplot2 visual density map: Visual density map by group and custom configuration geom_ The alpha parameter in the density function sets the image transparency (to prevent multiple density c
【学习笔记】阶段测试1
周大福践行「百周年承诺」,真诚服务推动绿色环保
Linux下mysql数据库安装教程
upload (1-6)
Leetcode array question brushing notes
The forked VM terminated without saying properly goodbye
openGauss数据库源码解析系列文章—— 密态等值查询技术详解(下)
Use the word "new" to attract curious people
Introduction, installation, introduction and detailed introduction to postman!
R language uses the polR function of mass package to build an ordered multi classification logistic regression model, and uses the coef function to obtain the log odds ratio corresponding to each vari
Google eventbus usage details
Why do mechanical engineers I know complain about low wages?
What is the ranking of GF futures? Is it safe and reliable to open an account for GF futures online?
关于memset赋值的探讨
SSH免密码登录详解
Laravel - model (new model and use model)
一网打尽异步神器CompletableFuture