#dates
// 使用标准区域设置格式格式化日期,也同样适用于数组、列表或集合
${#dates.format(date)}
${#dates.arrayFormat(datesArray)}
${#dates.listFormat(datesList)}
${#dates.setFormat(datesSet)}
// 使用ISO8601格式格式化日期,也同样适用于数组、列表或集合
${#dates.formatISO(date)}
${#dates.arrayFormatISO(datesArray)}
${#dates.listFormatISO(datesList)}
${#dates.setFormatISO(datesSet)}
// 使用指定的格式格式化日期,比如 ${#dates.format(date,'yyyy-MM-dd HH:mm:ss')}
${#dates.format(date, 'dd/MMM/yyyy HH:mm')}
${#dates.arrayFormat(datesArray, 'dd/MMM/yyyy HH:mm')}
${#dates.listFormat(datesList, 'dd/MMM/yyyy HH:mm')}
${#dates.setFormat(datesSet, 'dd/MMM/yyyy HH:mm')}
// 获取日期属性,也同样适用于数组、列表或集合
${#dates.day(date)}
${#dates.month(date)}
${#dates.monthName(date)}
${#dates.monthNameShort(date)}
${#dates.year(date)}
${#dates.dayOfWeek(date)}
${#dates.dayOfWeekName(date)}
${#dates.dayOfWeekNameShort(date)}
${#dates.hour(date)}
${#dates.minute(date)}
${#dates.second(date)}
${#dates.millisecond(date)}
// 根据year,month,day创建日期(java.util.Date)对象,比如 ${#dates.create('2008','08','08')}
${#dates.create(year,month,day)}
${#dates.create(year,month,day,hour,minute)}
${#dates.create(year,month,day,hour,minute,second)}
${#dates.create(year,month,day,hour,minute,second,millisecond)}
// 创建当前日期和时间创建日期(java.util.Date)对象,比如 ${#dates.format(#dates.createNow(),'yyyy-MM-dd HH:mm:ss')}
${#dates.createNow()}
${#dates.createNowForTimeZone()}
// 创建当前日期创建一个日期(java.util.Date)对象(时间设置为00:00)
${#dates.createToday()}
${#dates.createTodayForTimeZone()}
#numbers
// 设置最小整数位数
${#numbers.formatInteger(num,3)}
${#numbers.arrayFormatInteger(numArray,3)}
${#numbers.listFormatInteger(numList,3)}
${#numbers.setFormatInteger(numSet,3)}
// 设置最小整数位数和千位分隔符: 'POINT'、'COMMA'、'WHITESPACE'、'NONE' 或 'DEFAULT'(根据本地化)
${#numbers.formatInteger(num,3,'POINT')}
${#numbers.arrayFormatInteger(numArray,3,'POINT')}
${#numbers.listFormatInteger(numList,3,'POINT')}
${#numbers.setFormatInteger(numSet,3,'POINT')}
// 创建一个从x到y的整数序列(数组)
${#numbers.sequence(from,to)}
${#numbers.sequence(from,to,step)}
#strings
// 返回对象的字符串表示形式
${#strings.toString(obj)}
// 检查字符串是否为空(或NULL),在检查之前执行trim()操作
${#strings.isEmpty(name)}
${#strings.arrayIsEmpty(nameArr)}
${#strings.listIsEmpty(nameList)}
${#strings.setIsEmpty(nameSet)}
// 对字符串执行“isEmpty()”检查, 如果为false则返回它, 如果为true则默认为另一个指定的字符串
${#strings.defaultString(text,default)}
${#strings.arrayDefaultString(textArr,default)}
${#strings.listDefaultString(textList,default)}
${#strings.setDefaultString(textSet,default)}
// 检查字符串中是否包含字符串片段,也同样适用于数组、列表或集合
${#strings.contains(name,'ez')}
${#strings.containsIgnoreCase(name,'ez')}
// 检查字符串是否以片段开始或结束,也同样适用于数组、列表或集合
${#strings.startsWith(name,'Don')}
${#strings.endsWith(name,endingFragment)}
// 子串相关操作,也同样适用于数组、列表或集合
${#strings.indexOf(name,frag)} // 也可以是 array*、list* 或 set*
${#strings.substring(name,3,5)} // 也可以是 array*、list* 或 set*
${#strings.substringAfter(name,prefix)} // 也可以是 array*、list* 或 set*
${#strings.substringBefore(name,suffix)} // 也可以是 array*、list* 或 set*
${#strings.replace(name,'las','ler')} // 也可以是 array*、list* 或 set*
// 附加和前置,也同样适用于数组、列表或集合
${#strings.prepend(str,prefix)}
${#strings.append(str,suffix)}
// 大小写转换,也同样适用于数组、列表或集合
${#strings.toUpperCase(name)}
${#strings.toLowerCase(name)}
// 拆分和拼接
${#strings.arrayJoin(namesArray,',')}
${#strings.listJoin(namesList,',')}
${#strings.setJoin(namesSet,',')}
${#strings.arraySplit(namesStr,',')}
${#strings.listSplit(namesStr,',')}
${#strings.setSplit(namesStr,',')}
// 去除首位空格,也同样适用于数组、列表或集合
${#strings.trim(str)}
// 计算长度,也同样适用于数组、列表或集合
${#strings.length(str)}
// 缩写文本, 使其最大大小为n。如果文本较大, 它将被剪辑并在末尾附加“...”,也同样适用于数组、列表或集合
${#strings.abbreviate(str,10)}
// 将第一个字符转换为大写(反之亦然)
${#strings.capitalize(str)}
${#strings.unCapitalize(str)}
// 将每个单词的第一个字符转换为大写
${#strings.capitalizeWords(str)}
${#strings.capitalizeWords(str,delimiters)}
// 转义字符串
${#strings.escapeXml(str)}
${#strings.escapeJava(str)}
${#strings.escapeJavaScript(str)}
${#strings.unescapeJava(str)}
${#strings.unescapeJavaScript(str)}
// 空安全比较和连接
${#strings.equals(first, second)}
${#strings.equalsIgnoreCase(first, second)}
${#strings.concat(values...)}
${#strings.concatReplaceNulls(nullValue, values...)}
// 随机数
${#strings.randomAlphanumeric(count)}
#objects
// 当对象不为空时返回,否则返回默认值
${#objects.nullSafe(obj,default)}
${#objects.arrayNullSafe(objArray,default)}
${#objects.listNullSafe(objList,default)}
${#objects.setNullSafe(objSet,default)}
#bools
// 评估条件, 类似于 th:if 标签
${#bools.isTrue(obj)}
${#bools.arrayIsTrue(objArray)}
${#bools.listIsTrue(objList)}
${#bools.setIsTrue(objSet)}
// 用否定来评估条件,也同样适用于数组、列表或集合
${#bools.isFalse(cond)}
// 评估条件并执行与操作
${#bools.arrayAnd(condArray)}
${#bools.listAnd(condList)}
${#bools.setAnd(condSet)}
// 评估条件并执行或操作
${#bools.arrayOr(condArray)}
${#bools.listOr(condList)}
${#bools.setOr(condSet)}
#arrays
// 转换为数组, 试图推断数组组件类。
// 注意, 如果结果数组为空, 或者目标对象的元素不是全部相同的类, 则此方法将返回 Object[]
${#arrays.toArray(object)}
// 转换为指定组件类的数组
${#arrays.toStringArray(object)}
${#arrays.toIntegerArray(object)}
${#arrays.toLongArray(object)}
${#arrays.toDoubleArray(object)}
${#arrays.toFloatArray(object)}
${#arrays.toBooleanArray(object)}
// 计算数组长度
${#arrays.length(array)}
// 检查数组是否为空
${#arrays.isEmpty(array)}
// 检查数组中是否包含元素或元素集合
${#arrays.contains(array, element)}
${#arrays.containsAll(array, elements)}
#lists
// 转化为 list
${#lists.toList(object)}
// 计算大小
${#lists.size(list)}
// 判空
${#lists.isEmpty(list)}
// 检查list中是否包含元素或元素集合
${#lists.contains(list, element)}
${#lists.containsAll(list, elements)}
// 排序给定列表的副本。列表的成员必须实现comparable, 或者必须定义comparator。
${#lists.sort(list)}
${#lists.sort(list, comparator)}
#sets
// 转化为 set
${#sets.toSet(object)}
// 计算大小
${#sets.size(set)}
// 检查set是否为empty
${#sets.isEmpty(set)}
// 检查set中是否包含元素或元素集合
${#sets.contains(set, element)}
${#sets.containsAll(set, elements)}
#maps
// 计算大小
${#maps.size(map)}
// 检查map是否为空
${#maps.isEmpty(map)}
// 检查map中是否包含key/s或value/s
${#maps.containsKey(map, key)}
${#maps.containsAllKeys(map, keys)}
${#maps.containsValue(map, value)}
${#maps.containsAllValues(map, value)}
#aggregates
// 计算总和。如果数组或集合为空则返回null
${#aggregates.sum(array)}
${#aggregates.sum(collection)}
// 计算的平均值。如果数组或集合为空则返回nul
${#aggregates.avg(array)}
${#aggregates.avg(collection)}
#messages
/*
* Obtain externalized messages. Can receive a single key, a key plus arguments,
* or an array/list/set of keys (in which case it will return an array/list/set of
* externalized messages).
* If a message is not found, a default message (like '??msgKey??') is returned.
*/
${#messages.msg('msgKey')}
${#messages.msg('msgKey', param1)}
${#messages.msg('msgKey', param1, param2)}
${#messages.msg('msgKey', param1, param2, param3)}
${#messages.msgWithParams('msgKey', new Object[] {param1, param2, param3, param4})}
${#messages.arrayMsg(messageKeyArray)}
${#messages.listMsg(messageKeyList)}
${#messages.setMsg(messageKeySet)}
/*
* Obtain externalized messages or null. Null is returned instead of a default
* message if a message for the specified key is not found.
*/
${#messages.msgOrNull('msgKey')}
${#messages.msgOrNull('msgKey', param1)}
${#messages.msgOrNull('msgKey', param1, param2)}
${#messages.msgOrNull('msgKey', param1, param2, param3)}
${#messages.msgOrNullWithParams('msgKey', new Object[] {param1, param2, param3, param4})}
${#messages.arrayMsgOrNull(messageKeyArray)}
${#messages.listMsgOrNull(messageKeyList)}
${#messages.setMsgOrNull(messageKeySet)}
#ids
/*
* Normally used in th:id attributes, for appending a counter to the id attribute value
* so that it remains unique even when involved in an iteration process.
*/
${#ids.seq('someId')}
/*
* Normally used in th:for attributes in <label> tags, so that these labels can refer to Ids
* generated by means if the #ids.seq(...) function.
*
* Depending on whether the <label> goes before or after the element with the #ids.seq(...)
* function, the "next" (label goes before "seq") or the "prev" function (label goes after
* "seq") function should be called.
*/
${#ids.next('someId')}
${#ids.prev('someId')}
————————————————
版权声明:本文为CSDN博主「梁云亮」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/lianghecai52171314/article/details/106394943/