后台代码:
//查询数据
List baobiaoAskforleave = baobiaoAskforleaveService.selectloading(id);
mmap.put("listmap", baobiaoAskforleave);
页面代码:
<ul th:each="c, State : ${listmap}">
     <li th:text="${c.post_name}" ></li>
     <li th:text="${c.leader_remark}"></li>
</ul>
使用Thymeleaf 心得体会:
假如你是使用了一对多的,对象里有个list 那么在它的子标签,你就该这样写了(此处为了拓展 我还用了th:if )
<ul th:each="c, State : ${listmap}">
        <li th:text="${c.post_name}" ></li>
       <!--下面这个就是我说的对象中 还存在list $就该换成* 去展示了 (c,State 这两个值 都是自己随意定义的)-->
        <li th:each="c, State : *{statulist}">
              <!--如果它的值是1 就显示这个-->
              <div class="col-sm-8" th:if="${c.status}  eq 1">
                    <li><input type="radio" checked />已批准</li>
                    <li><input type="radio" />申请中</li>
                </div>
          <!-- 如果它的值是0 就显示这个-->
                <div class="col-sm-8" th:if="${c.status}  eq 0">
                    <li><input type="radio" />已批准</li>
                    <li><input type="radio" checked />申请中</li>
                </div>
        </li>
</ul>
原文:https://www.cnblogs.com/gjths/p/12200073.html