Есть ли способ использовать оператор Java instanceof
в Thymeleaf?
Что-то типа:
<span th:if="${animal} instanceof my.project.Cat" th:text="A cat"></span>
<span th:if="${animal} instanceof my.project.Dog" th:text="A dog"></span>
Есть ли способ использовать оператор Java instanceof
в Thymeleaf?
Что-то типа:
<span th:if="${animal} instanceof my.project.Cat" th:text="A cat"></span>
<span th:if="${animal} instanceof my.project.Dog" th:text="A dog"></span>
Пытаться:
<span th:if="${animal.class.name == 'my.project.Cat'}" th:text="A cat"></span>
или, если используется Spring:
<span th:if="${animal instanceof T(my.project.Cat)}" th:text="A cat"></span>
подробнее об использовании SpEL и диалекты в тимелеафе.