Има ли начин да се използва операторът 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 и диалекти в thymeleaf.