数组

  • #arrays: 用于数组的实用方法。
  1. /*
  2. * ======================================================================
  3. * See javadoc API for class org.thymeleaf.expression.Arrays
  4. * ======================================================================
  5. */
  6. /*
  7. * Converts to array, trying to infer array component class.
  8. * Note that if resulting array is empty, or if the elements
  9. * of the target object are not all of the same class,
  10. * this method will return Object[].
  11. */
  12. ${#arrays.toArray(object)}
  13. /*
  14. * Convert to arrays of the specified component class.
  15. */
  16. ${#arrays.toStringArray(object)}
  17. ${#arrays.toIntegerArray(object)}
  18. ${#arrays.toLongArray(object)}
  19. ${#arrays.toDoubleArray(object)}
  20. ${#arrays.toFloatArray(object)}
  21. ${#arrays.toBooleanArray(object)}
  22. /*
  23. * Compute length
  24. */
  25. ${#arrays.length(array)}
  26. /*
  27. * Check whether array is empty
  28. */
  29. ${#arrays.isEmpty(array)}
  30. /*
  31. * Check if element or elements are contained in array
  32. */
  33. ${#arrays.contains(array, element)}
  34. ${#arrays.containsAll(array, elements)}