How to use custom Spring EL function in Thymeleaf?
Not in front of a way to test, but offhand try using the static call:
th:text="${T(com.package.SUtils).reverseString('hello')}"
What I usually do, is to define Thymeleaf utility classes like this as a Bean using @Component
. In Spring EL you can then simply refer to them using @
with auto-detection. So there is no need to register them.
@Component
public interface SUtils {
static String reverseString(String input) {
// ...
}
}
<span th:text="${@sUtils.reverseString('hello')}"></span>