月度小总结 :Thymeleaf 常用点
Thymeleaf 笔记
项目中随手记得笔记,后面会不定时完善
1 使用标准
< html xmlns:th=“http://www.thymeleaf.org”>
2 导入外部链接
< link rel=“stylesheet” type=“text/css” media=“all” href="…/…/css/gtvg.css" th:href="@{/css/gtvg.css}" />
< link rel=“stylesheet” type=“text/css” media=“all” href="…/…/css/gtvg.css" data-th-href="@{/css/gtvg.css}" />
< script th:src="@{http://libs.baidu.com/jquery/2.1.4/jquery.min.js}">
< script th:src="@{/js/common.js}">
3 Springboot 使用
spring.thymeleaf.prefix=classpath:/templates/
spring.thymeleaf.suffix=.html
Maven 依赖
org.springframework.boot
spring-boot-starter-thymeleaf
4 模板引用
语法 :~{templatename::fragmentname}
templatename : 模板名 , Thymeleaf会根据模版名解析完整路径
fragmentname : 片段名 ,支持ID ~{templatename::#id}
1 th:inssert : 保留当前主标签,保留th:fragment主标签;
<footer th:fragment="copy">
<script type="text/javascript" th:src="@{/plugins/jquery/jquery-3.0.2.js}"></script>
</footer>
---->
<div th:insert="footer :: copy"></div>
---->
<div>
<footer>
<script type="text/javascript" th:src="@{/plugins/jquery/jquery-3.0.2.js}"></script>
</footer>
</div>
// 保留了fragment,和DIV
2 th:replace : 舍弃当前主标签,保留th:fragment主标签;
<div th:replace="footer :: copy"></div>
<footer>
<script type="text/javascript" th:src="@{/plugins/jquery/jquery-3.0.2.js}"></script>
</footer>
//DIV 没有保留
3 th:include : 保留当前主标签,舍弃th:fragment主标签。
step 1 准备 完整模板 header.html
<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org"
xmlns:layout="http://www.ultrag.net.nz/thymeleaf/layout">
<head>
<meta charset="UTF-8">
<title>Thymeleaf in action</title>
</head>
<body>
<div th:fragment="header">
<h1>Thymeleaf in action</h1>
<a href="/users" >首页</a>
</div>
</body>
</html>
step 2 导入
< div th:replace="~{fragments/header::header}"></div>
< head th:replace="../templates/system/index/headLink :: links"></hea
?路径以templates 为基准的相对路径 ,具体应该是设置的
<span th:include="pages/fragments/header/head-css::common-css"></span>
thymeleaf 注释
1 > 页面源码不可看到
<!--/* aaaa */-->
Spring MVC 使用
类中 1 @RestController
或者 2 @Controller 但是是JSON格式
标准表达式语法
${…} : 变量表达式。
*{…} : 选择表达式。
#{…} : 消息 (i18n) 表达式。
@{…} : 链接 (URL) 表达式。
~{…} : 片段表达式
表达式基本对象
1、#ctx:上下文对象
2、#vars:上下文变量
3、#locale:上下文语言环境
4、#httpServletRequest:(只有在Web上下文)HttpServletRequest对象
5、#httpSession:(只有在Web上下文)HttpSession对象。
实用工具对象
dates: java.util的实用方法。对象:日期格式、组件提取等.
calendars:类似于#日期,但对于java.util。日历对象
numbers:格式化数字对象的实用方法。
strings:字符串对象的实用方法:包含startsWith,将/附加等。
objects:实用方法的对象。
bools:布尔评价的实用方法。
arrays:数组的实用方法。
lists:list集合。
sets:set集合。
maps:map集合。
aggregates:实用程序方法用于创建聚集在数组或集合.
messages:实用程序方法获取外部信息内部变量表达式,以同样的方式,因为它们将获得使用# {…}语法
ids:实用程序方法来处理可能重复的id属性(例如,由于迭代)。
链接地址
1 . 绝对网址
< a th:href="@{https://www.yiibai.com/thymeleaf/}">
< a href=“https://www.yiibai.com/thymeleaf/”>
2 . 上下文相对URL
< a th:href="@{/order/list}">
< a href="/applicationpath/order/list">
3 . 服务器上下文 , 不链接到应用查询上下文资源
< a th:href="@{~/billing-app/showDetails.html}">
< a href="/billing-app/showDetails.html">
? - 此处没有加上应用程序路径
4 . 协议相关URL
< script th:src="@{//scriptserver.example.net/myscript.js}">…
< script src="//scriptserver.example.net/myscript.js">…
5 . 添加参数
< a th:href="@{/order/details(id=3)}">
< a href="/order/details?id=3">
< a th:href="@{/order/details(id=3,action=‘show_all’)}"> === 添加多参数
< a th:href="@{/order/{id}/details(id=3,action=‘show_all’)}"> === 使用占位符
< a href="/order/3/details?action=show_all">
6 . 网址片段标识符
< a th:href="@{/home#all_info(action=‘show’)}">
< a href="/home?action=show#all_info">
7 . URL重写
8 . URL 使用表达式
- < a th:href="@{/order/details(id={user.admin} ? ‘show_all’ : ‘show_public’))}">
配置
org.thymeleaf.templateresolver.ClassLoaderTemplateResolver :
–》 return Thread.currentThread().getContextClassLoader().getResourceAsStream(template);
org.thymeleaf.templateresolver.FileTemplateResolver
–》 return new FileInputStream(new File(template));
org.thymeleaf.templateresolver.UrlTemplateResolver
–》 return (new URL(template)).openStream();
org.thymeleaf.templateresolver.StringTemplateResolver
–》 return new StringReader(templateName);
设置前后缀
templateResolver.setPrefix("/WEB-INF/templates/");
templateResolver.setSuffix(".html");
templateResolver.addTemplateAlias("adminHome","profiles/admin/home");
templateResolver.setTemplateAliases(aliasesMap);
templateResolver.setEncoding("UTF-8");
templateResolver.setCacheable(false);
templateResolver.getCacheablePatternSpec().addPattern("/users/*");
templateResolver.setCacheTTLMs(60000L);
JavaBean 使用
使用Bean 的值
-
model.addAttribute(“product”, product);
-
<div th:object="*{customer}">
<p><b>Name:</b> <span th:text="*{name}">Frederic Tomato</span></p>
...
</div>
前端对象
一、ctx :上下文对象。
二、vars :上下文变量。
三、locale:上下文的语言环境。
四、request:(仅在web上下文)的 HttpServletRequest 对象。
五、response:(仅在web上下文)的 HttpServletResponse 对象。
六、session:(仅在web上下文)的 HttpSession 对象。
七、servletContext:(仅在web上下文)的 ServletContext 对象
一、strings:字符串格式化方法,常用的Java方法它都有。比如:equals,equalsIgnoreCase,length,trim,toUpperCase,toLowerCase,indexOf,substring,replace,startsWith,endsWith,contains,containsIgnoreCase等
二、numbers:数值格式化方法,常用的方法有:formatDecimal等
三、bools:布尔方法,常用的方法有:isTrue,isFalse等
四、arrays:数组方法,常用的方法有:toArray,length,isEmpty,contains,containsAll等
五、lists,sets:集合方法,常用的方法有:toList,size,isEmpty,contains,containsAll,sort等
六、maps:对象方法,常用的方法有:size,isEmpty,containsKey,containsValue等
七、dates:日期方法,常用的方法有:format,year,month,hour,createNow等
常用
1 > th:value : 设置值
<input type="text" name="userName" value="Yiibai" th:value="${user.name}" />
2 > each 循环
<tr th:each="user:${userModel.userList}">
<td th:text="${user.id}"></td>
<td th:text="${user.email}"></td>
</tr>
3 > if 判断
? - - if 判断通过则会生成该代码
<tr th:if="${userModel.userList.size()} eq 0">
4 > 文本
<span th:text="${recipient}"></span>
5 > form 表单提交
<form action="/users" th:action="@{/users}" method="POST" th:object="${userModel.user}">
<input type="text" name="name" th:value="*{name}">
<input type="submit" value="提交" >
</form>
6 > 格式输出
//小数格式化
<dd th:text="${'¥' + #numbers.formatDecimal(product.price, 1, 2)}">100</dd>
//日期格式化
<dd th:text="${#dates.format(product.availableFrom, 'yyyy-MM-dd')}">28-Jun-2018</dd>
7 > 字符串转义
<div th:utext="${html}">Some unescaped text</div>
//当后台传递的参数是一段HTML代码的时候 , 通过该方法进行字符串转义
8 > 显示 bean 参数
<div th:object="${session.user}">
<p>Name: <span th:text="${#object.firstName}">Sebastian</span>.</p>
<p>Surname: <span th:text="${session.user.lastName}">Pepper</span>.</p>
<p>Nationality: <span th:text="*{nationality}">Saturn</span>.</p>
</div>
9 > th:block : 用于表示代码块
10 > th:if : 条件判断
11 > th:object : 声明变量
12 > 链接跳转
<a th:href="@{getshop}" class=""><i class="lnr lnr-code"></i> <span>店铺设置</span></a>
13 > ModelAndView
modelAndView.addObject("shopModel",shopService.getShop(gsid));
<input name="shopname" th:type="text" th:value="${shopModel.shopname}">
//前端红线报错是正常现象
后记
#ctx : context 容器对象 ( org.thymeleaf.context.IContext 或者 org.thymeleaf.context.IWebContext )
- ${#ctx.locale}
- ${#ctx.variableNames}
- ${#ctx.request}
- ${#ctx.response}
- ${#ctx.session}
- ${#ctx.servletContext}
#request : 获取请求对象 ( 同理session , context )
- ${#request.getAttribute(‘foo’)}
- ${#request.getParameter(‘foo’)}
- ${#request.getContextPath()}
- ${#request.getRequestName()}
- ${#session.getAttribute(‘foo’)}
- ${#session.id}
- ${#session.lastAccessedTime}
- ${#servletContext.getAttribute(‘foo’)}
- ${#servletContext.contextPath}
param : 请求参数 , 获取param 中的参数
- ${param.foo}
- ${param.size()}
- ${param.isEmpty()}
- ${param.containsKey(‘foo’)}
session : 获取 Session 域参数
- ${session.foo}
- ${session.size()}
- ${session.isEmpty()}
- ${session.containsKey(‘foo’)}
application : 获取Application参数
- ${application.foo}
- ${application.size()}
- ${application.isEmpty()}
- ${application.containsKey(‘foo’)}
#execInfo : 表达式对象 , 用于返回模板的有用信息
- ${#execInfo.templateName} === 注意插入模板返回的是插入的模板名
- ${#execInfo.templateMode}
- ${#execInfo.processedTemplateName}
- ${#execInfo.processedTemplateMode}
- ${#execInfo.templateNames}
- ${#execInfo.templateModes}
- ${#execInfo.templateStack}
#messages : 用于获取外部消息
- ${#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)}
- ${#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)}
#uris : 用于在thymeleaf 中执行url 操作
- ${#uris.escapePath(uri)}
- ${#uris.escapePath(uri, encoding)}
- ${#uris.unescapePath(uri)}
- ${#uris.unescapePath(uri, encoding)}
- ${#uris.escapePathSegment(uri)}
- ${#uris.escapePathSegment(uri, encoding)}
- ${#uris.unescapePathSegment(uri)}
- ${#uris.unescapePathSegment(uri, encoding)}
- ${#uris.escapeFragmentId(uri)}
- ${#uris.escapeFragmentId(uri, encoding)}
- ${#uris.unescapeFragmentId(uri)}
- ${#uris.unescapeFragmentId(uri, encoding)}
- ${#uris.escapeQueryParam(uri)}
- ${#uris.escapeQueryParam(uri, encoding)}
- ${#uris.unescapeQueryParam(uri)}
- ${#uris.unescapeQueryParam(uri, encoding)}
#conversions : 用于将对象转换为指定的类型
- ${#conversions.convert(object, ‘java.util.TimeZone’)}
- ${#conversions.convert(object, targetClass)}
#dates : java.util.Date 工具类
- ${#dates.format(date)}
- ${#dates.arrayFormat(datesArray)}
- ${#dates.listFormat(datesList)}
- ${#dates.setFormat(datesSet)}
- ${#dates.formatISO(date)}
- ${#dates.arrayFormatISO(datesArray)}
- ${#dates.listFormatISO(datesList)}
- ${#dates.setFormatISO(datesSet)}
- ${#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)} // also arrayDay(…), listDay(…), etc.
- ${#dates.month(date)} // also arrayMonth(…), listMonth(…), etc.
- ${#dates.monthName(date)} // also arrayMonthName(…), listMonthName(…), etc.
- ${#dates.monthNameShort(date)} // also arrayMonthNameShort(…), listMonthNameShort(…), etc.
- ${#dates.year(date)} // also arrayYear(…), listYear(…), etc.
- ${#dates.dayOfWeek(date)} // also arrayDayOfWeek(…), listDayOfWeek(…), etc.
- ${#dates.dayOfWeekName(date)} // also arrayDayOfWeekName(…), listDayOfWeekName(…), etc.
- ${#dates.dayOfWeekNameShort(date)} // also arrayDayOfWeekNameShort(…), listDayOfWeekNameShort(…), etc.
- ${#dates.hour(date)} // also arrayHour(…), listHour(…), etc.
- ${#dates.minute(date)} // also arrayMinute(…), listMinute(…), etc.
- ${#dates.second(date)} // also arraySecond(…), listSecond(…), etc.
- ${#dates.millisecond(date)} // also arrayMillisecond(…), listMillisecond(…), etc.
- ${#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)}
- ${#dates.createNow()}
- ${#dates.createNowForTimeZone()}
- ${#dates.createToday()}
- ${#dates.createTodayForTimeZone()}
#Calendars java.util.Calendar 对象 ,区别于date对象
- ${#calendars.format(cal)}
- ${#calendars.arrayFormat(calArray)}
- ${#calendars.listFormat(calList)}
- ${#calendars.setFormat(calSet)}
- ${#calendars.formatISO(cal)}
- ${#calendars.arrayFormatISO(calArray)}
- ${#calendars.listFormatISO(calList)}
- ${#calendars.setFormatISO(calSet)}
- ${#calendars.format(cal, ‘dd/MMM/yyyy HH:mm’)}
- ${#calendars.arrayFormat(calArray, ‘dd/MMM/yyyy HH:mm’)}
- ${#calendars.listFormat(calList, ‘dd/MMM/yyyy HH:mm’)}
- ${#calendars.setFormat(calSet, ‘dd/MMM/yyyy HH:mm’)}
- ${#calendars.day(date)} // also arrayDay(…), listDay(…), etc.
- ${#calendars.month(date)} // also arrayMonth(…), listMonth(…), etc.
- ${#calendars.monthName(date)} // also arrayMonthName(…), listMonthName(…), etc.
- ${#calendars.monthNameShort(date)} // also arrayMonthNameShort(…), listMonthNameShort(…), etc.
- ${#calendars.year(date)} // also arrayYear(…), listYear(…), etc.
- ${#calendars.dayOfWeek(date)} // also arrayDayOfWeek(…), listDayOfWeek(…), etc.
- ${#calendars.dayOfWeekName(date)} // also arrayDayOfWeekName(…), listDayOfWeekName(…), etc.
- ${#calendars.dayOfWeekNameShort(date)} // also arrayDayOfWeekNameShort(…), listDayOfWeekNameShort(…), etc.
- ${#calendars.hour(date)} // also arrayHour(…), listHour(…), etc.
- ${#calendars.minute(date)} // also arrayMinute(…), listMinute(…), etc.
- ${#calendars.second(date)} // also arraySecond(…), listSecond(…), etc.
- ${#calendars.millisecond(date)} // also arrayMillisecond(…), listMillisecond(…), etc.
- ${#calendars.create(year,month,day)}
- ${#calendars.create(year,month,day,hour,minute)}
- ${#calendars.create(year,month,day,hour,minute,second)}
- ${#calendars.create(year,month,day,hour,minute,second,millisecond)}
- ${#calendars.createForTimeZone(year,month,day,timeZone)}
- ${#calendars.createForTimeZone(year,month,day,hour,minute,timeZone)}
- ${#calendars.createForTimeZone(year,month,day,hour,minute,second,timeZone)}
- ${#calendars.createForTimeZone(year,month,day,hour,minute,second,millisecond,timeZone)}
- ${#calendars.createNow()}
- ${#calendars.createNowForTimeZone()}
- ${#calendars.createToday()}
- ${#calendars.createTodayForTimeZone()}
#Numbers
- ${#numbers.formatInteger(num,3)}
- ${#numbers.arrayFormatInteger(numArray,3)}
- ${#numbers.listFormatInteger(numList,3)}
- ${#numbers.setFormatInteger(numSet,3)}
- ${#numbers.formatInteger(num,3,‘POINT’)}
- ${#numbers.arrayFormatInteger(numArray,3,‘POINT’)}
- ${#numbers.listFormatInteger(numList,3,‘POINT’)}
- ${#numbers.setFormatInteger(numSet,3,‘POINT’)}
- ${#numbers.formatDecimal(num,3,2)}
- ${#numbers.arrayFormatDecimal(numArray,3,2)}
- ${#numbers.listFormatDecimal(numList,3,2)}
- ${#numbers.setFormatDecimal(numSet,3,2)}
- ${#numbers.formatDecimal(num,3,2,‘COMMA’)}
- ${#numbers.arrayFormatDecimal(numArray,3,2,‘COMMA’)}
- ${#numbers.listFormatDecimal(numList,3,2,‘COMMA’)}
- ${#numbers.setFormatDecimal(numSet,3,2,‘COMMA’)}
- ${#numbers.formatDecimal(num,3,‘POINT’,2,‘COMMA’)}
- ${#numbers.arrayFormatDecimal(numArray,3,‘POINT’,2,‘COMMA’)}
- ${#numbers.listFormatDecimal(numList,3,‘POINT’,2,‘COMMA’)}
- ${#numbers.setFormatDecimal(numSet,3,‘POINT’,2,‘COMMA’)}
- ${#numbers.formatCurrency(num)}
- ${#numbers.arrayFormatCurrency(numArray)}
- ${#numbers.listFormatCurrency(numList)}
- ${#numbers.setFormatCurrency(numSet)}
- ${#numbers.formatPercent(num)}
- ${#numbers.arrayFormatPercent(numArray)}
- ${#numbers.listFormatPercent(numList)}
- ${#numbers.setFormatPercent(numSet)}
- ${#numbers.formatPercent(num, 3, 2)}
- ${#numbers.arrayFormatPercent(numArray, 3, 2)}
- ${#numbers.listFormatPercent(numList, 3, 2)}
- ${#numbers.setFormatPercent(numSet, 3, 2)}
- ${#numbers.sequence(from,to)}
- ${#numbers.sequence(from,to,step)}
Strings : StringObject
- ${#strings.toString(obj)} // also array*, list* and set*
- ${#strings.isEmpty(name)}
- ${#strings.arrayIsEmpty(nameArr)}
- ${#strings.listIsEmpty(nameList)}
- ${#strings.setIsEmpty(nameSet)}
- ${#strings.defaultString(text,default)}
- ${#strings.arrayDefaultString(textArr,default)}
- ${#strings.listDefaultString(textList,default)}
- ${#strings.setDefaultString(textSet,default)}
- ${#strings.contains(name,‘ez’)} // also array*, list* and set*
- ${#strings.containsIgnoreCase(name,‘ez’)} // also array*, list* and set*
- ${#strings.startsWith(name,‘Don’)} // also array*, list* and set*
- ${#strings.endsWith(name,endingFragment)} // also array*, list* and set*
- ${#strings.indexOf(name,frag)} // also array*, list* and set*
- ${#strings.substring(name,3,5)} // also array*, list* and set*
- ${#strings.substringAfter(name,prefix)} // also array*, list* and set*
- ${#strings.substringBefore(name,suffix)} // also array*, list* and set*
- ${#strings.replace(name,‘las’,‘ler’)} // also array*, list* and set*
- ${#strings.prepend(str,prefix)} // also array*, list* and set*
- ${#strings.append(str,suffix)} // also array*, list* and set*
- ${#strings.toUpperCase(name)} // also array*, list* and set*
- ${#strings.toLowerCase(name)} // also array*, list* and set*
- ${#strings.arrayJoin(namesArray,’,’)}
- ${#strings.listJoin(namesList,’,’)}
- ${#strings.setJoin(namesSet,’,’)}
- ${#strings.arraySplit(namesStr,’,’)} // returns String[]
- ${#strings.listSplit(namesStr,’,’)} // returns List
- ${#strings.setSplit(namesStr,’,’)} // returns Set
- ${#strings.trim(str)} // also array*, list* and set*
- ${#strings.length(str)} // also array*, list* and set*
- ${#strings.abbreviate(str,10)} // also array*, list* and set*
- ${#strings.capitalize(str)} // also array*, list* and set*
- ${#strings.unCapitalize(str)} // also array*, list* and set*
- ${#strings.capitalizeWords(str)} // also array*, list* and set*
- ${#strings.capitalizeWords(str,delimiters)} // also array*, list* and set*
- ${#strings.escapeXml(str)} // also array*, list* and set*
- ${#strings.escapeJava(str)} // also array*, list* and set*
- ${#strings.escapeJavaScript(str)} // also array*, list* and set*
- ${#strings.unescapeJava(str)} // also array*, list* and set*
- ${#strings.unescapeJavaScript(str)} // also array*, list* and set*
- ${#strings.equals(first, second)}
- ${#strings.equalsIgnoreCase(first, second)}
- ${#strings.concat(values…)}
- ${#strings.concatReplaceNulls(nullValue, values…)}
- ${#strings.randomAlphanumeric(count)}
Objects : object 对象
- ${#objects.nullSafe(obj,default)}
- ${#objects.arrayNullSafe(objArray,default)}
- ${#objects.listNullSafe(objList,default)}
- ${#objects.setNullSafe(objSet,default)}
Booleans : #bools 对象
- ${#bools.isTrue(obj)}
- ${#bools.arrayIsTrue(objArray)}
- ${#bools.listIsTrue(objList)}
- ${#bools.setIsTrue(objSet)}
- ${#bools.isFalse(cond)}
- ${#bools.arrayIsFalse(condArray)}
- ${#bools.listIsFalse(condList)}
- ${#bools.setIsFalse(condSet)}
- ${#bools.arrayAnd(condArray)}
- ${#bools.listAnd(condList)}
- ${#bools.setAnd(condSet)}
- ${#bools.arrayOr(condArray)}
- ${#bools.listOr(condList)}
- ${#bools.setOr(condSet)}
Arrays
- ${#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 :
- ${#lists.toList(object)}
- ${#lists.size(list)}
- ${#lists.isEmpty(list)}
- ${#lists.contains(list, element)}
- ${#lists.containsAll(list, elements)}
- ${#lists.sort(list)}
- ${#lists.sort(list, comparator)}
Sets :
- ${#sets.toSet(object)}
- ${#sets.size(set)}
- ${#sets.isEmpty(set)}
- ${#sets.contains(set, element)}
- ${#sets.containsAll(set, elements)}
Maps :
- ${#maps.size(map)}
- ${#maps.isEmpty(map)}
- ${#maps.containsKey(map, key)}
- ${#maps.containsAllKeys(map, keys)}
- ${#maps.containsValue(map, value)}
- ${#maps.containsAllValues(map, value)}
Aggregates : 用于数组统计
- ${#aggregates.sum(array)}
- ${#aggregates.sum(collection)}
- ${#aggregates.avg(array)}
- ${#aggregates.avg(collection)}