十、屬性優先順序 十一、註釋 11.1 <!-- ... --> 同HTML/XML的註釋 11.2 thymeleaf解析器註釋 thymeleaf解析的時候會被註釋,靜態打開時會顯示 單行 <!--/* ... */--> 多行時: <!--/*--> ... ... <!--/*--> 11.3 ...
十、屬性優先順序
十一、註釋
11.1 <!-- ... --> 同HTML/XML的註釋
<!-- User info follows --> <div th:text="${...}"> ... </div>
11.2 thymeleaf解析器註釋
thymeleaf解析的時候會被註釋,靜態打開時會顯示
單行 <!--/* ... */-->
<!--/* This code will be removed at thymeleaf parsing time! */-->
多行時:
<!--/*-->
...
...
<!--/*-->
<!--/*--> <div> you can see me only before thymeleaf processes me! </div> <!--*/-->
11.3 靜態解析時被註釋,thymeleaf解析時會移除<!--/*/ 和 /*/-->標簽對,內容保留
<span>hello!</span> <!--/*/ <div th:text="${...}"> ... </div> /*/--> <span>goodbye!</span>
這個註釋在寫th:block的時候很有用哦
<table> <!--/*/ <th:block th:each="user : ${users}"> /*/--> <tr> <td th:text="${user.login}">...</td> <td th:text="${user.name}">...</td> </tr> <tr> <td colspan="2" th:text="${user.address}">...</td> </tr> <!--/*/ </th:block> /*/--> </table>
11.4 th:block 適用於比如說要迴圈兩個<tr>
it could be useful, for example, when creating iterated tables that require more than one <tr> for each element