当前位置:网站首页>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 make a second clip of our media video without infringement
- Scenario based technology architecture process based on tidb - Theory
- What are the advantages and characteristics of SAS interface
- VC开发非MFC程序内存泄漏跟踪代码
- Login interface code
- LeetCode_ 67 (binary sum)
- Guofu hydrogen energy rushes to the scientific and Technological Innovation Board: it plans to raise 2billion yuan, and 360million yuan of accounts receivable exceed the revenue
- R language ggplot2 visualization: use ggplot2 to visualize the scatter diagram, and use the labs parameter to customize the X axis label text (customize X axis labels)
- 日化用品行业智能供应链协同系统解决方案:数智化SCM供应链,为企业转型“加速度”
- 鸿蒙第四次培训
猜你喜欢

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

How to deeply understand the design idea of "finite state machine"?

openGauss数据库源码解析系列文章—— 密态等值查询技术详解(下)

魅族新任董事長沈子瑜:創始人黃章先生將作為魅族科技產品戰略顧問

让秒杀狂欢更从容:大促背后的数据库(下篇)

SAS接口有什么优势特点

Qingda KeYue rushes to the science and Innovation Board: the annual revenue is 200million, and it is proposed to raise 750million

What category does the Internet of things application technology major belong to

Current situation, trend and view of neural network Internet of things in the future

TiFlash 源码解读(四) | TiFlash DDL 模块设计及实现分析
随机推荐
Detailed explanation of SSH password free login
Current situation, trend and view of neural network Internet of things in the future
展现强大。这样手机就不会难前进
日化用品行业智能供应链协同系统解决方案:数智化SCM供应链,为企业转型“加速度”
How does redis implement multiple zones?
Faire un clip vidéo auto - média deux fois, comment clip n'est pas considéré comme une infraction
广发期货排名多少?网上办理广发期货开户安全可靠吗?
鸿蒙第四次培训
Tiflash compiler oriented automatic vectorization acceleration
基于伯努利原理的速度监测芯片可用于天然气管道泄露检测
Interpretation of tiflash source code (IV) | design and implementation analysis of tiflash DDL module
用“新”字来吸引好奇的人群
R语言使用MASS包的polr函数构建有序多分类logistic回归模型、使用coef函数获取模型中每个变量(自变量改变一个单位)对应的对数优势比(log odds ratio)
最简单不用证书也可以多开功能的方式
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
分享 20 个稀奇古怪的 JS 表达式,看看你能答对多少
After the microservice project is deployed, static resources and files uploaded to upload cannot be accessed. Solution
openGauss数据库源码解析系列文章—— 密态等值查询技术详解(下)
Why do mechanical engineers I know complain about low wages?
Webrtc learning (II)