thymeleaf expressions

Thmeleaf Message (i18n) expression

Spring Message Resolver Config @Bean @Description(“Spring Message Resolver”) public ResourceBundleMessageSource messageSource() { ResourceBundleMessageSource messageSource = new ResourceBundleMessageSource(); messageSource.setBasename(“messages”); return messageSource; } messages.propertioes Dosyasi name=dogukan Thmeleaf html dosyasi <p th:text=”#{name}”>Name</p> Cikti <p>dogukan</p>  

Thymeleaf th:each

Degiskenler String[] names = {“dogukan”,”onur”,”mehmet”}; model.addAttribute(“names”, names); Ornek 1 <ul> <li th:each=”name:${names}” th:text=”${name}”>Name</li> </ul> <ul> <li>dogukan</li> <li>onur</li> <li>mehmet</li> </ul> Ornek 2 <ul> <li th:each=”name,i:${names}”> <p th:text=”${name}”> Name</p> <p th:text=”${i.index}”>0</p> <p th:text=”${i.size}”>3</p> <p th:text=”${i.even}”>true</p> </li> </ul> <ul> <li> <p>dogukan</p> <p>0</p> <p>3</p> <p>false</p> </li> <li> <p>onur</p> <p>1</p> <p>3</p> <p>true</p> </li> <li> <p>mehmet</p> <p>2</p> <p>3</p> <p>false</p> </li> </ul> …

Thymeleaf th:each Read More »

Thymeleaf th:if th:unless

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 …

Thymeleaf th:if th:unless Read More »