How can I check in Thymeleaf if a spring bean exists

Viewed 335

I am writting a Thymeleaf template that would get some data from a spring bean. My project is using spring-boot (if it matters). There are situations when a certain bean is not available. How can I check inside the template if a bean exists or not ?

I tried like checking a variable, but it doesn't work

<div th:if="${@myBean != null}" th:text="Bean exists"></div>

I get a

NoSuchBeanDefinitionException: No bean named 'myBean' available

1 Answers
Related