thymeleaf循環 下標

 後端

    @GetMapping()
	public String c(ModelMap mmap) {
		List<Com> slist = companyService.selectCompanyList();
		mmap.put("cList", slist);
		return "/clist";
	}

 

前端

<select name="coId">
	<option value="">所有</option>
	<option th:each="c ,cStat: ${cList}" th:text="${c.name}" th:value="${c.id}"  th:data-index="${cStat.index}" >

</select>

cStat是狀態變量,有 index,count,size,current,even,odd,first,last等屬性,如果沒有顯示設置狀態變量,thymeleaf會默 認給個“變量名+Stat"的狀態變量。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章