如何在春季百里香中将值重新分配给全局定义的变量

时间:2018-06-23 13:54:39

标签: java spring spring-mvc thymeleaf

这是我尝试过的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变量。

我怎么能做到这一点?

0 个答案:

没有答案