Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <h1>Conditional Expression</h1>
- <h2>If-then</h2>
- <p th:text="${person1.address} ? ${person1.address.street}">Default
- person1 Street</p>
- <p th:text="${person2.address} ? ${person2.address.street}">Default
- person2 Street</p>
- <h2>If-then-else</h2>
- <p
- th:text="${person1.address} ? ${person1.address.zipcode} : 'not exist'">Default
- Zipcode 1</p>
- <p
- th:text="${person2.address} ? ${person2.address.zipcode} : 'Person2 does not have an address'">Default
- Zipcode 2</p>
- <h2>Elvis Operator</h2>
- <p th:text="${person1.address}?:'not exist'">Default address1</p>
- <p th:text="${person2.address}?:'Person2 does not have an address...'">Default
- address2</p>
- <h2>If-Unless</h2>
- <p th:if="${person1.id == 1}" th:text="${person1.address}"></p>
- <p th:unless="${person2.id == 1}" th:text="${person2.address}"></p>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement