这是我尝试过的html代码。
<body th:with="firstId=null,lastId='123'">
<table>
<tr th:each="document, state : ${data}">
<td th:with="firstId = ${state.first ? document[_id] : 'abc'}" th:text="${firstId}"></td>
</table>
<div th:text="${firstId}">something</div>
</body>
我想要实现的是我只想给firstId变量分配第一个值,并且在循环完成后我想在标记后的循环外打印firstId变量。
我怎么能做到这一点?