当前位置:网站首页>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>
边栏推荐
- Discussion on memset assignment
- R语言ggplot2可视化条形图:通过双色渐变配色颜色主题可视化条形图、为每个条形添加标签文本(geom_text函数)
- Sorter evolution of ticdc 6.0 principle
- R语言dplyr包select函数、group_by函数、mutate函数、cumsum函数计算dataframe分组数据中指定数值变量的累加值、并生成累加数据列
- 乌卡时代下,企业供应链管理体系的应对策略
- 日化用品行业智能供应链协同系统解决方案:数智化SCM供应链,为企业转型“加速度”
- Implementation process of WSDL and soap calls under PHP5
- How does redis implement multiple zones?
- 基于伯努利原理的速度监测芯片可用于天然气管道泄露检测
- 别不服气。手机功能升级就是强
猜你喜欢
The IPO of Ruineng industry was terminated: the annual revenue was 447million and it was planned to raise 376million
区间 - 左闭右开
Current situation, trend and view of neural network Internet of things in the future
Why do mechanical engineers I know complain about low wages?
Interpretation of tiflash source code (IV) | design and implementation analysis of tiflash DDL module
Tidb DM alarm DM_ sync_ process_ exists_ with_ Error troubleshooting
非技术部门,如何参与 DevOps?
What category does the Internet of things application technology major belong to
网上电子元器件采购商城:打破采购环节信息不对称难题,赋能企业高效协同管理
Oneconnect listed in Hong Kong: with a market value of HK $6.3 billion, ye Wangchun said that he was honest and trustworthy, and long-term success
随机推荐
Sharing the 12 most commonly used regular expressions can solve most of your problems
Login interface code
Redis如何实现多可用区?
最简单不用证书也可以多开功能的方式
循环不变式
R language ggplot2 visualization: gganimate package is based on Transition_ The time function creates dynamic scatter animation (GIF) and uses shadow_ Mark function adds static scatter diagram as anim
Thymeleaf th:with局部变量的使用
LeetCode_ 2 (add two numbers)
TDengine 社区问题双周精选 | 第三期
无密码身份验证如何保障用户隐私安全?
最长公共子序列 - 动态规划
04_solr7.3之solrJ7.3的使用
Current situation, trend and view of neural network Internet of things in the future
关于memset赋值的探讨
日化用品行业智能供应链协同系统解决方案:数智化SCM供应链,为企业转型“加速度”
POI set the data format of the column (valid)
R language uses the multinom function of NNET package to build an unordered multi classification logistic regression model, and uses the coef function to obtain the log odds ratio corresponding to eac
Detailed explanation of IP address and preparation of DOS basic commands and batch processing
分享 12 个最常用的正则表达式,能解决你大部分问题
享你所想。智创未来