Advertisement
andersonalmada

Untitled

Jul 1st, 2022
1,197
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 0.83 KB | None | 0 0
  1.     <h1>Conditional Expression</h1>
  2.     <h2>If-then</h2>
  3.     <p th:text="${person1.address} ? ${person1.address.street}">Default
  4.         person1 Street</p>
  5.     <p th:text="${person2.address} ? ${person2.address.street}">Default
  6.         person2 Street</p>
  7.  
  8.     <h2>If-then-else</h2>
  9.     <p
  10.         th:text="${person1.address} ? ${person1.address.zipcode} : 'not exist'">Default
  11.         Zipcode 1</p>
  12.     <p
  13.         th:text="${person2.address} ? ${person2.address.zipcode} : 'Person2 does not have an address'">Default
  14.         Zipcode 2</p>
  15.  
  16.     <h2>Elvis Operator</h2>
  17.     <p th:text="${person1.address}?:'not exist'">Default address1</p>
  18.     <p th:text="${person2.address}?:'Person2 does not have an address...'">Default
  19.         address2</p>
  20.  
  21.     <h2>If-Unless</h2>
  22.     <p th:if="${person1.id == 1}" th:text="${person1.address}"></p>
  23.     <p th:unless="${person2.id == 1}" th:text="${person2.address}"></p>
  24.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement