Thymeleaf is designed for the Java applications template engine. The engine has implemented several utility objects that can be used to perform special operations on template variables. In this article, we will present utility methods for
Arrays. The implementation of
Arrays utility methods can be found in the official Thymeleaf GitHub Repository.
2. Available utility methods for
Thymeleaf comes with several utility methods for Arrays.
||Converts to array, trying to infer array component class||If resulting array is empty, or if the elements of the target object are not all of the same class, this method will return
||Convert to arrays of the specified component class|
||Get array length|
||Check whether array is empty|
||Check if array contains given element or all elements|
In this article, we presented Thymeleaf utility methods for
Arrays which are commonly used objects in applications. The utility should be useful to check the size of an array, check if an array contains a specific element or group of elements.