当前位置:网站首页>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>
边栏推荐
- C - Divisors of the Divisors of An Integer Gym - 102040C
- Geom of R language using ggplot2 package_ Histogram function visual histogram (histogram plot)
- CYCA少儿形体礼仪 宁波市培训成果考核圆满落幕
- 神经网络物联网未来发展趋势怎么样
- Linux下mysql数据库安装教程
- R语言使用nnet包的multinom函数构建无序多分类logistic回归模型、使用coef函数获取模型中每个变量(自变量改变一个单位)对应的对数优势比(log odds ratio)
- 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
- 汇编语言 assembly language
- TiFlash 源码解读(四) | TiFlash DDL 模块设计及实现分析
- 01. Solr7.3.1 deployment and configuration of jetty under win10 platform
猜你喜欢

Simple process of penetration test

Sharing the 12 most commonly used regular expressions can solve most of your problems

分享 12 个最常用的正则表达式,能解决你大部分问题

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

TiFlash 源码解读(四) | TiFlash DDL 模块设计及实现分析

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

Principle and performance analysis of lepton lossless compression

Postman简介、安装、入门使用方法详细攻略!

TiFlash 面向编译器的自动向量化加速

SAS接口有什么优势特点
随机推荐
Hongmeng fourth training
根据CronSequenceGenerator计算cron表达式的时间
日化用品行业智能供应链协同系统解决方案:数智化SCM供应链,为企业转型“加速度”
The IPO of Ruineng industry was terminated: the annual revenue was 447million and it was planned to raise 376million
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
享你所想。智创未来
Use the word "new" to attract curious people
mysql 自定义函数 身份证号转年龄(支持15/18位身份证)
The simplest way to open more functions without certificates
[buuctf.reverse] 152-154
【学习笔记】阶段测试1
SAS接口有什么优势特点
Simple process of penetration test
Thymeleaf th:classappend属性追加 th:styleappend样式追加 th:data-自定义属性
The speed monitoring chip based on Bernoulli principle can be used for natural gas pipeline leakage detection
ASP. Net large takeout ordering system source code (PC version + mobile version + merchant version)
【学习笔记】图的连通性与回路
Sharing the 12 most commonly used regular expressions can solve most of your problems
无密码身份验证如何保障用户隐私安全?
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)