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"的状态变量。

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