thymeleaf / select option list遍历循环

匿名 (未验证) 提交于 2019-12-03 00:05:01

<option th:each="car,userStat:${carList}" th:value="${car.carId}" th:text="${car.name}"></option>

 

  
  1. <div class="form-group">

  2.     <label for="parentId" class="col-sm-2 control-label">车</label>

  3.     <div class="col-sm-8">

  4.         <select name="carIs" id="carId" class="form-control1">

  5.             <option th:each="car,userStat:${carList}" th:value="${car.carId}" th:text="${car.name}"></option>

  6.         </select>

  7.     </div>

  8. </div>

选中的情况下

返回的map中有2个值

一个是carList 一个是car

  
  1. <option th:each="list,userStat:${carList}" th:value="${list.carId}" th:text="${car.name}"

  2. th:selected="${list.carId == car.carId}"></option>

参考地址 https://blog.csdn.net/tuntun1120/article/details/79849273

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!