当前位置:网站首页>Fonctions communes de thymeleaf
Fonctions communes de thymeleaf
2022-07-05 14:17:00 【Fengyehongworld】
Table des matières
- Un.. #dates
- 2.. #numbers
- Trois. #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`
- Quatre. #objects
- Cinq. #bools
Un.. #dates
Traitement des données de date.Générer,Conversion, Obtenir le nombre exact de jours et d'années pour la date .
#dates.createNow
Générer la date actuelle (équivalent àJavaDenew Date())
<span th:text="${#dates.createNow()}"></span>
<!--Page des résultats-->
<span>Sun May 16 09:38:33 CST 2021</span>
#dates.create
- Construire une date
<span th:text="${#dates.create('2019','05','31','10','18')}"></span>
<!--Page des résultats-->
<span>Fri May 31 10:18:00 CST 2019</span>
#dates.format
- Formater la date
- Lors du formatage de la date , La date doit être
new Date()Type, Impossible d'être un type de date de chaîne ,Sinon, une erreur sera signalée.
<span th:text="*{#dates.format(#dates.createNow())}"></span>
<!--Page des résultats-->
<span>2021Année5Mois16Jour Matin09Heure40Points46Secondes</span>
- Formater la date dans le format spécifié
<span th:text="*{#dates.format(#dates.createNow(), 'yyyy/MM/dd HH:mm')}"></span>
<!--Page des résultats-->
<span>2021/05/16 09:43</span>
<span th:text="*{#dates.format(#dates.createNow(), 'yyyyAnnéeMMMoisddJour HH:mm')}"></span>
<!--Page des résultats-->
<span>2021Année05Mois16Jour 09:43</span>
#dates.year
- Année d'acquisition
<span th:text="*{#dates.year(#dates.createNow())}"></span>
<!--Page des résultats-->
<span>2021</span>
#dates.month
- Obtenir le mois( En ligne )
<span>[[*{#dates.month(#dates.createNow())}]]</span>
<!--Page des résultats-->
<span>5</span>
#dates.monthName
<span th:text="*{#dates.monthName(#dates.createNow())}"></span>
<!--Page des résultats-->
<span>Mai</span>
#dates.monthNameShort
<span th:text="*{#dates.monthNameShort(#dates.createNow())}"></span>
<!--Page des résultats-->
<span>Mai</span>
#dates.day
- Date d'acquisition
<span th:text="*{#dates.day(#dates.createNow())}"></span>
<!--Page des résultats-->
<span>30</span>
#dates.dayOfWeek
Obtenez le jour de la semaine ( La situation à l'étranger , Dimanche est le premier jour de la semaine )
<span th:text="*{#dates.dayOfWeek(#dates.createNow())}"></span>
<!--Page des résultats-->
<span>1</span>
#dates.dayOfWeekName
<span th:text="*{#dates.dayOfWeekName(#dates.createNow())}"></span>
<!--Page des résultats-->
<span>Dimanche</span>
#dates.dayOfWeekNameShort
<span th:text="*{#dates.dayOfWeekNameShort(#dates.createNow())}"></span>
<!--Page des résultats-->
<span>Dimanche</span>
#dates.hour
- Obtenir l'heure actuelle
<span th:text="*{#dates.hour(#dates.createNow())}"></span>
<!--Page des résultats-->
<span>10</span>
#dates.minute
- Obtenir la minute actuelle
<span th:text="*{#dates.minute(#dates.createNow())}"></span>
<!--Page des résultats-->
<span>6</span>
#dates.second
- Obtenez la seconde courante
<span th:text="*{#dates.second(#dates.createNow())}"></span>
<!--Page des résultats-->
<span>12</span>
#dates.millisecond
- Obtient le nombre actuel de millisecondes
<span th:text="*{#dates.millisecond(#dates.createNow())}"></span>
<!--Page des résultats-->
<span>221</span>
2.. #numbers
Traitement de la conversion des données numériques
- Pour compléter un nombre qui n'est pas assez grand 0(formatInteger)
- Définir le séparateur de milliers (formatInteger)
- Point décimal exact (formatDecimal)
- Réglez le pourcentage (formatPercent)
- Générer un tableau(sequence)
#numbers.formatInteger
- Pour compléter un nombre qui n'est pas assez grand 0
<p th:text="${#numbers.formatInteger('123',4)}"></p> // 0123
<p th:text="${#numbers.formatInteger('123',2)}"></p> // 123
- Définir le séparateur de milliers
.
<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
Définir le séparateur de milliers ,
<p th:text="${#numbers.formatInteger('1000', 2, 'COMMA')}"></p> // 1,000
<div th:text="*{#numbers.formatInteger('1000', 0, 'COMMA')}"></div> // 1,000
Définir le séparateur de milliers à blanc
<p th:text="${#numbers.formatInteger('1000', 2, 'WHITESPACE')}"></p> // 1 000
#numbers.formatDecimal
Point décimal exact
<p th:text="${#numbers.formatDecimal('10.123', 3, 2)}"></p> // 010.12
#numbers.formatCurrency
Symbole d'affichage de l'argent
<p th:text="${#numbers.formatCurrency('1000')}"></p> // ¥1,000.00
#numbers.formatPercent
Opérations en pourcentage
<p th:text="${#numbers.formatPercent('0.2',2, 4)}"></p> // 20.0000%
<p th:text="${#numbers.formatPercent('0.2',3, 2)}"></p> // 020.00%
Trois. #strings
- Conversion de chaîne(toString)
- Vérifiez si la chaîne est vide(isEmpty)
- La chaîne est une opération de remplacement vide (defaultString)
- Vérifiez si la chaîne contient une chaîne (contains containsIgnoreCase)
- Vérifiez si la chaîne commence ou se termine par un fragment (startsWith endsWith)
- Interception(substring substringAfter)
- Remplacer(replace)
- Annexe(prepend append)
- Changer le cas (toUpperCase toLowerCase)
- Diviser et combiner les chaînes (arrayJoin arraySplit)
- Va dans l'espace(trim)
- Texte abrégé (abbreviate)
- Connexion à chaîne(concat)
#strings.toString
// javaCode
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,'La valeur estnull')}"></p>
<p>La valeur estnull</p>
<p th:text="${#strings.defaultString(text1,'La valeur estnull')}"></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>
Quatre. #objects
#objects.nullSafe
<p th:text="${#objects.nullSafe(null,'L'objet estnull')}"></p>
<p>L'objet estnull</p>
Cinq. #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>
边栏推荐
- How to deeply understand the design idea of "finite state machine"?
- 3W principle [easy to understand]
- Thymeleaf 常用函数
- Qingda KeYue rushes to the science and Innovation Board: the annual revenue is 200million, and it is proposed to raise 750million
- R语言ggplot2可视化条形图:通过双色渐变配色颜色主题可视化条形图、为每个条形添加标签文本(geom_text函数)
- 03_ Dataimport of Solr
- 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
- R语言dplyr包select函数、group_by函数、mutate函数、cumsum函数计算dataframe分组数据中指定数值变量的累加值、并生成累加数据列
- 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
- LeetCode_ 67 (binary sum)
猜你喜欢

Getting started with rce

Lepton 无损压缩原理及性能分析

OSI and tcp/ip protocol cluster

非技术部门,如何参与 DevOps?

The IPO of Ruineng industry was terminated: the annual revenue was 447million and it was planned to raise 376million

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

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 面向编译器的自动向量化加速

How to protect user privacy without password authentication?

ASP. Net large takeout ordering system source code (PC version + mobile version + merchant version)
随机推荐
R语言ggplot2可视化密度图:按照分组可视化密度图、自定义配置geom_density函数中的alpha参数设置图像透明度(防止多条密度曲线互相遮挡)
How to make a second clip of our media video without infringement
故障分析 | MySQL 耗尽主机内存一例分析
Don't be unconvinced. Mobile phone function upgrade is strong
CYCA少儿形体礼仪 宁波市培训成果考核圆满落幕
R语言ggplot2可视化:可视化折线图、使用theme函数中的legend.position参数自定义图例的位置
R Language ggplot2 Visualization: visualize linegraph, using Legend in Theme function. Paramètre de position emplacement de la légende personnalisée
R语言ggplot2可视化:gganimate包基于transition_time函数创建动态散点图动画(gif)、使用shadow_mark函数为动画添加静态散点图作为动画背景
日化用品行业智能供应链协同系统解决方案:数智化SCM供应链,为企业转型“加速度”
The forked VM terminated without saying properly goodbye
物联网应用技术专业是属于什么类
What category does the Internet of things application technology major belong to
Detailed explanation of IP address and preparation of DOS basic commands and batch processing
关于Apache Mesos的一些想法
Sharing the 12 most commonly used regular expressions can solve most of your problems
LeetCode_ 2 (add two numbers)
How does redis implement multiple zones?
R language ggplot2 visual bar graph: visualize the bar graph through the two-color gradient color theme, and add label text for each bar (geom_text function)
R语言dplyr包select函数、group_by函数、mutate函数、cumsum函数计算dataframe分组数据中指定数值变量的累加值、并生成累加数据列
IP packet header analysis and static routing