当前位置:网站首页>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>
边栏推荐
- 04_solr7.3之solrJ7.3的使用
- 动态规划
- Hongmeng fourth training
- The forked VM terminated without saying properly goodbye
- R语言ggplot2可视化:gganimate包基于transition_time函数创建动态散点图动画(gif)、使用shadow_mark函数为动画添加静态散点图作为动画背景
- Interpretation of tiflash source code (IV) | design and implementation analysis of tiflash DDL module
- Google EventBus 使用详解
- 判断变量是否为数组
- LeetCode_ 67 (binary sum)
- 分享 20 个稀奇古怪的 JS 表达式,看看你能答对多少
猜你喜欢

Opengauss database source code analysis series articles -- detailed explanation of dense equivalent query technology (Part 2)

Interpretation of tiflash source code (IV) | design and implementation analysis of tiflash DDL module

Redis如何实现多可用区?

Thymeleaf th:classappend属性追加 th:styleappend样式追加 th:data-自定义属性

循环不变式

Shenziyu, the new chairman of Meizu: Mr. Huang Zhang, the founder, will serve as the strategic adviser of Meizu's scientific and technological products

Sqllab 1-6 exercise

Shen Ziyu, nouveau Président de Meizu: M. Huang Zhang, fondateur de Meizu, agira comme conseiller stratégique pour les produits scientifiques et technologiques de Meizu

What are the advantages and characteristics of SAS interface

How does redis implement multiple zones?
随机推荐
CYCA少儿形体礼仪 宁波市培训成果考核圆满落幕
怎么叫一手一机的功能方式
Tdengine biweekly selection of community issues | phase III
OSI and tcp/ip protocol cluster
Leetcode array question brushing notes
How can non-technical departments participate in Devops?
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
Laravel - view (new and output views)
非技术部门,如何参与 DevOps?
What are the advantages and characteristics of SAS interface
IP packet header analysis and static routing
Sorter evolution of ticdc 6.0 principle
判断变量是否为数组
Which Internet companies are worth going to in Shenzhen for software testers [Special Edition for software testers]
乌卡时代下,企业供应链管理体系的应对策略
How does redis implement multiple zones?
LeetCode_ 69 (square root of x)
01 、Solr7.3.1 在Win10平台下使用jetty的部署及配置
做自媒體視頻二次剪輯,怎樣剪輯不算侵權
R语言ggplot2可视化:gganimate包基于transition_time函数创建动态散点图动画(gif)、使用shadow_mark函数为动画添加静态散点图作为动画背景