Thymeleaf th:if th:unless

Posted by dogukanhan on September 03, 2018 · 1 min read

Degiskenler

model.addAttribute("variable", "dogukan");
model.addAttribute("variableBoolean",true);
model.addAttribute("variableBoolean2",false);

 

<div th:if="false" th:text="${variable}"> Test Variable </div>

=Cikti yok

<div th:if="true" th:text="${variable}"> Test Variable </div>

=dogukan

<div th:if="${variableBoolean && variableBoolean2}" th:text="${variable}"> Test Variable </div>

=Cikti yok

<div th:if="${variableBoolean || variableBoolean2}" th:text="${variable}"> Test Variable </div>

=dogukan

<div th:if="${variable == 'dogukan'}" th:text="${variable}"> Test Variable </div>

=dogukan

<div th:if="${variable3 != null}" th:text="${variable}"> Test Variable </div>

=Cikti yok

<div th:if="${variable.charAt(0) == 'd'}" th:text="${variable}"> Test Variable </div>

=Cikti Yok

<div th:if="${variable.charAt(0).toString() == 'd'}" th:text="${variable}"> Test Variable </div>

=dogukan

<div th:unless="false" th:text="${variable}"> Test Variable </div>

=dogukan