Thymeleaf模板表达式大全

日期格式、组件提取等.

  1. ${#dates.format(date)}
  2. ${#dates.arrayFormat(datesArray)}
  3. ${#dates.listFormat(datesList)}
  4. ${#dates.setFormat(datesSet)}
  5. ${#dates.format(date, 'yyyy-MM-dd HH:mm:ss')}
  6. ${#dates.arrayFormat(datesArray, 'dd/MMM/yyyy HH:mm')}
  7. ${#dates.listFormat(datesList, 'dd/MMM/yyyy HH:mm')}
  8. ${#dates.setFormat(datesSet, 'dd/MMM/yyyy HH:mm')}
  9. ${#dates.day(date)}
  10. ${#dates.month(date)}
  11. ${#dates.monthName(date)}
  12. ${#dates.monthNameShort(date)}
  13. ${#dates.year(date)}
  14. ${#dates.dayOfWeek(date)}
  15. ${#dates.dayOfWeekName(date)}
  16. ${#dates.dayOfWeekNameShort(date)}
  17. ${#dates.hour(date)}
  18. ${#dates.minute(date)}
  19. ${#dates.second(date)}
  20. ${#dates.millisecond(date)}
  21. ${#dates.create(year,month,day)}
  22. ${#dates.create(year,month,day,hour,minute)}
  23. ${#dates.create(year,month,day,hour,minute,second)}
  24. ${#dates.create(year,month,day,hour,minute,second,millisecond)}
  25. ${#dates.createNow()}
  26. ${#dates.createToday()}

 

日历

  1. ${#calendars.format(cal)}
  2. ${#calendars.arrayFormat(calArray)}
  3. ${#calendars.listFormat(calList)}
  4. ${#calendars.setFormat(calSet)}
  5. ${#calendars.format(cal, 'dd/MMM/yyyy HH:mm')}
  6. ${#calendars.arrayFormat(calArray, 'dd/MMM/yyyy HH:mm')}
  7. ${#calendars.listFormat(calList, 'dd/MMM/yyyy HH:mm')}
  8. ${#calendars.setFormat(calSet, 'dd/MMM/yyyy HH:mm')}
  9. ${#calendars.day(date)}
  10. ${#calendars.month(date)}
  11. ${#calendars.monthName(date)}
  12. ${#calendars.monthNameShort(date)}
  13. ${#calendars.year(date)}
  14. ${#calendars.dayOfWeek(date)}
  15. ${#calendars.dayOfWeekName(date)}
  16. ${#calendars.dayOfWeekNameShort(date)}
  17. ${#calendars.hour(date)}
  18. ${#calendars.minute(date)}
  19. ${#calendars.second(date)}
  20. ${#calendars.millisecond(date)}
  21. ${#calendars.create(year,month,day)}
  22. ${#calendars.create(year,month,day,hour,minute)}
  23. ${#calendars.create(year,month,day,hour,minute,second)}
  24. ${#calendars.create(year,month,day,hour,minute,second,millisecond)}
  25. ${#calendars.createNow()}
  26. ${#calendars.createToday()}

 

格式化数字对象

  1. ${#numbers.formatInteger(num,3)}
  2. ${#numbers.arrayFormatInteger(numArray,3)}
  3. ${#numbers.listFormatInteger(numList,3)}
  4. ${#numbers.setFormatInteger(numSet,3)}
  5. ${#numbers.formatInteger(num,3,'POINT')}
  6. ${#numbers.arrayFormatInteger(numArray,3,'POINT')}
  7. ${#numbers.listFormatInteger(numList,3,'POINT')}
  8. ${#numbers.setFormatInteger(numSet,3,'POINT')}
  9. ${#numbers.formatDecimal(num,3,2)}
  10. ${#numbers.arrayFormatDecimal(numArray,3,2)}
  11. ${#numbers.listFormatDecimal(numList,3,2)}
  12. ${#numbers.setFormatDecimal(numSet,3,2)}
  13. ${#numbers.formatDecimal(num,3,2,'COMMA')}
  14. ${#numbers.arrayFormatDecimal(numArray,3,2,'COMMA')}
  15. ${#numbers.listFormatDecimal(numList,3,2,'COMMA')}
  16. ${#numbers.setFormatDecimal(numSet,3,2,'COMMA')}
  17. ${#numbers.formatDecimal(num,3,'POINT',2,'COMMA')}
  18. ${#numbers.arrayFormatDecimal(numArray,3,'POINT',2,'COMMA')}
  19. ${#numbers.listFormatDecimal(numList,3,'POINT',2,'COMMA')}
  20. ${#numbers.setFormatDecimal(numSet,3,'POINT',2,'COMMA')}
  21. ${#numbers.sequence(from,to)}
  22. ${#numbers.sequence(from,to,step)}

 

字符串处理

  1. ${#strings.isEmpty(name)}
  2. ${#strings.arrayIsEmpty(nameArr)}
  3. ${#strings.listIsEmpty(nameList)}
  4. ${#strings.setIsEmpty(nameSet)}
  5. ${#strings.defaultString(text,default)}
  6. ${#strings.arrayDefaultString(textArr,default)}
  7. ${#strings.listDefaultString(textList,default)}
  8. ${#strings.setDefaultString(textSet,default)}
  9. ${#strings.contains(name,'ez')}
  10. ${#strings.containsIgnoreCase(name,'ez')}
  11. ${#strings.startsWith(name,'Don')}
  12. ${#strings.endsWith(name,endingFragment)}
  13. ${#strings.indexOf(name,frag)}
  14. ${#strings.substring(name,3,5)}
  15. ${#strings.substringAfter(name,prefix)}
  16. ${#strings.substringBefore(name,suffix)}
  17. ${#strings.replace(name,'las','ler')}
  18. ${#strings.prepend(str,prefix)}
  19. ${#strings.append(str,suffix)}
  20. ${#strings.toUpperCase(name)}
  21. ${#strings.toLowerCase(name)}
  22. ${#strings.arrayJoin(namesArray,',')}
  23. ${#strings.listJoin(namesList,',')}
  24. ${#strings.setJoin(namesSet,',')}
  25. ${#strings.arraySplit(namesStr,',')}
  26. ${#strings.listSplit(namesStr,',')}
  27. ${#strings.setSplit(namesStr,',')}
  28. ${#strings.trim(str)}
  29. ${#strings.length(str)}
  30. ${#strings.abbreviate(str,10)}
  31. ${#strings.capitalize(str)}
  32. ${#strings.unCapitalize(str)}
  33. ${#strings.capitalizeWords(str)}
  34. ${#strings.capitalizeWords(str,delimiters)}
  35. ${#strings.escapeXml(str)}
  36. ${#strings.escapeJava(str)}
  37. ${#strings.escapeJavaScript(str)}
  38. ${#strings.unescapeJava(str)}
  39. ${#strings.unescapeJavaScript(str)}
  40. ${#strings.equals(str)}
  41. ${#strings.equalsIgnoreCase(str)}
  42. ${#strings.concat(str)}
  43. ${#strings.concatReplaceNulls(str)}

 

对象处理

  1. ${#objects.nullSafe(obj,default)}
  2. ${#objects.arrayNullSafe(objArray,default)}
  3. ${#objects.listNullSafe(objList,default)}
  4. ${#objects.setNullSafe(objSet,default)}

 

布尔值相关

  1. ${#bools.isTrue(obj)}
  2. ${#bools.arrayIsTrue(objArray)}
  3. ${#bools.listIsTrue(objList)}
  4. ${#bools.setIsTrue(objSet)}
  5. ${#bools.isFalse(cond)}
  6. ${#bools.arrayIsFalse(condArray)}
  7. ${#bools.listIsFalse(condList)}
  8. ${#bools.setIsFalse(condSet)}
  9. ${#bools.arrayAnd(condArray)}
  10. ${#bools.listAnd(condList)}
  11. ${#bools.setAnd(condSet)}
  12. ${#bools.arrayOr(condArray)}
  13. ${#bools.listOr(condList)}
  14. ${#bools.setOr(condSet)}

 

数组相关

  1. ${#arrays.toArray(object)}
  2. ${#arrays.toStringArray(object)}
  3. ${#arrays.toIntegerArray(object)}
  4. ${#arrays.toLongArray(object)}
  5. ${#arrays.toDoubleArray(object)}
  6. ${#arrays.toFloatArray(object)}
  7. ${#arrays.toBooleanArray(object)}
  8. ${#arrays.length(array)}
  9. ${#arrays.isEmpty(array)}
  10. ${#arrays.contains(array, element)}
  11. ${#arrays.containsAll(array, elements)}

 

list集合相关

  1. ${#lists.toList(object)}
  2. ${#lists.size(list)}
  3. ${#lists.isEmpty(list)}
  4. ${#lists.contains(list, element)}
  5. ${#lists.containsAll(list, elements)}
  6. ${#lists.sort(list)}
  7. ${#lists.sort(list, comparator)}

 

set集合相关

  1. ${#sets.toSet(object)}
  2. ${#sets.size(set)}
  3. ${#sets.isEmpty(set)}
  4. ${#sets.contains(set, element)}
  5. ${#sets.containsAll(set, elements)}

 

map集合相关

  1. ${#maps.size(map)}
  2. ${#maps.isEmpty(map)}
  3. ${#maps.containsKey(map, key)}
  4. ${#maps.containsAllKeys(map, keys)}
  5. ${#maps.containsValue(map, value)}
  6. ${#maps.containsAllValues(map, value)}

 

聚集,聚合

  1. ${#aggregates.sum(array)}
  2. ${#aggregates.sum(collection)}
  3. ${#aggregates.avg(array)}
  4. ${#aggregates.avg(collection)}

 

获取外部信息内部变量

  1. ${#messages.msg('msgKey')}
  2. ${#messages.msg('msgKey', param1)}
  3. ${#messages.msg('msgKey', param1, param2)}
  4. ${#messages.msg('msgKey', param1, param2, param3)}
  5. ${#messages.msgWithParams('msgKey', new Object[] {param1, param2, param3, param4})}
  6. ${#messages.arrayMsg(messageKeyArray)}
  7. ${#messages.listMsg(messageKeyList)}
  8. ${#messages.setMsg(messageKeySet)}
  9. ${#messages.msgOrNull('msgKey')}
  10. ${#messages.msgOrNull('msgKey', param1)}
  11. ${#messages.msgOrNull('msgKey', param1, param2)}
  12. ${#messages.msgOrNull('msgKey', param1, param2, param3)}
  13. ${#messages.msgOrNullWithParams('msgKey', new Object[] {param1, param2, param3, param4})}
  14. ${#messages.arrayMsgOrNull(messageKeyArray)}
  15. ${#messages.listMsgOrNull(messageKeyList)}
  16. ${#messages.setMsgOrNull(messageKeySet)}

 

处理可能重复的id属性

  1. ${#ids.seq('someId')}
  2. ${#ids.next('someId')}
  3. ${#ids.prev('someId')}

 

  • 微信
  • 交流学习,有偿服务
  • weinxin
  • 博客/Java交流群
  • 资源分享,问题解决,技术交流。群号:590480292
  • weinxin
言曌

发表评论

:?::razz::sad::evil::!::smile::oops::grin::eek::shock::???::cool::lol::mad::twisted::roll::wink::idea::arrow::neutral::cry::mrgreen: