thymeleaf th: falls Beispiel
<td>
<span th:if="${teacher.gender == 'F'}">Female</span>
<span th:unless="${teacher.gender == 'F'}">Male</span>
</td>
Tame Tortoise
<td>
<span th:if="${teacher.gender == 'F'}">Female</span>
<span th:unless="${teacher.gender == 'F'}">Male</span>
</td>
<td th:text="${teacher.active} ? 'ACTIVE' : 'RETIRED'" />
public class Teacher implements Serializable {
private String gender;
private boolean isActive;
private List<String> courses = new ArrayList<>();
private String additionalSkills;
<dependency>
<groupId>org.thymeleaf</groupId>
<artifactId>thymeleaf</artifactId>
<version>3.0.11.RELEASE</version>
</dependency>
<dependency>
<groupId>org.thymeleaf</groupId>
<artifactId>thymeleaf-spring5</artifactId>
<version>3.0.11.RELEASE</version>
</dependency>
<td th:text="${teacher.additionalSkills} ?: 'UNKNOWN'" />
<td th:switch="${#lists.size(teacher.courses)}">
<span th:case="'0'">NO COURSES YET!</span>
<span th:case="'1'" th:text="${teacher.courses[0]}"></span>
<div th:case="*">
<div th:each="course:${teacher.courses}" th:text="${course}"/>
</div>
</td>