当前位置:网站首页>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>
边栏推荐
- 【学习笔记】阶段测试1
- mysql 自定义函数 身份证号转年龄(支持15/18位身份证)
- 世界环境日 | 周大福用心服务推动减碳环保
- 01. Solr7.3.1 deployment and configuration of jetty under win10 platform
- 判断变量是否为数组
- R语言ggplot2可视化:gganimate包基于transition_time函数创建动态散点图动画(gif)、使用shadow_mark函数为动画添加静态散点图作为动画背景
- poi设置列的数据格式(有效)
- 04_solr7.3之solrJ7.3的使用
- 汇编语言 assembly language
- 无密码身份验证如何保障用户隐私安全?
猜你喜欢

What is the future development trend of neural network Internet of things

Detailed explanation of IP address and preparation of DOS basic commands and batch processing

无密码身份验证如何保障用户隐私安全?

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

OSI and tcp/ip protocol cluster

Zhizhen new energy rushes to the scientific innovation board: the annual revenue is 220million, and SAIC venture capital is the shareholder

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

基于 TiDB 场景式技术架构过程 - 理论篇

软件测试人在深圳有哪些值得去的互联网公司【软件测试人员专供版】

openGauss数据库源码解析系列文章—— 密态等值查询技术详解(下)
随机推荐
Which Internet companies are worth going to in Shenzhen for software testers [Special Edition for software testers]
网上电子元器件采购商城:打破采购环节信息不对称难题,赋能企业高效协同管理
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
How to protect user privacy without password authentication?
享你所想。智创未来
神经网络物联网未来现状和趋势及看法
世界环境日 | 周大福用心服务推动减碳环保
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)
神经网络物联网未来发展趋势怎么样
物联网应用技术专业是属于什么类
微服务项目部署后,无法访问静态资源,无法访问到上传到upload中的文件,解决办法
无密码身份验证如何保障用户隐私安全?
Sharing the 12 most commonly used regular expressions can solve most of your problems
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
C语言中限定符的作用
R语言使用原生包(基础导入包、graphics)中的boxplot函数可视化箱图(box plot)
Google EventBus 使用详解
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