天天看點

SpringBoot中thymeleaf的th:each用法,給name動态指派

做一個功能,在頁面動态增加人員資訊,頁面如下圖

當我修改這條資料時,需要回顯,可能是多條,背景用的List<實體> 接收的,name格式必須是locationPersonnel[0].tel,是以就要用th:each的下表拼接這種寫法了;

<div class="panel panel-custom" th:each="locationPersonnel,locationPersonnelStat : ${locationPersonnelList}">

th:attr="name='locationPersonnel['+${locationPersonnelStat.index}+'].name'"
我是這樣給name屬性動态指派的,寫好好久好久了。

記住這是用于多條資料修改回顯的時候寫的,至于注冊的時候,自己用js拼接就OK了
           

若描述不争取請加 739749855qq詳解

SpringBoot中thymeleaf的th:each用法,給name動态指派

繼續閱讀