programing

Thymeleaf에서 의 인스턴스 사용

cafebook 2023. 7. 27. 22:19
반응형

Thymeleaf에서 의 인스턴스 사용

Java를 사용할 수 있는 방법이 있습니까?instanceofThymeleaf에 있는 교환원?

다음과 같은 것:

<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>

또는 스프링을 사용하는 경우:

<span th:if="${animal instanceof T(my.project.Cat)}" th:text="A cat"></span>

타임리프에서 SpEL과 방언사용하는 것에 대해 자세히 알아봅니다.

언급URL : https://stackoverflow.com/questions/28783272/use-instanceof-in-thymeleaf

반응형