在jsp中循环遍历一个数据,根据数据的某些属性给节点填充不一样的内容:可以使用如下方法             <c:forEach items="${menu}" var="entry">
                  <c:choose>
                   <c:when test="${entry.menuGroup == 1}">
                        <li>选择一</li>
                   </c:when>
                   <c:otherwise>
                         <li>选择二</li>
                   </c:otherwise>
                  <c:choose>
              </c:forEach>可在Thymeleaf中如何达到这种效果
             
            <li th:each ="entry,star:${menu}>
                     如何才能通过判断entry来实现不一样的<li>节点呢,each里面如何使用th:if才能达到上面一段jsp代码类似的效果
            </li>

解决方案 »

  1.   

    th:each  
    th:if
    th:less
      

  2.   

     th:if = “${entry.menuGroup eq 1}”
      

  3.   

     <tr  th:each="xt,xtStat : ${vo.sjXt}">
                <td th:text="${xtStat.first==true?xt.shXm:''}"></td>
                <td>
                    <input th:id="sjXt+${xtStat.index}" class="mini-checkbox" type="checkbox"  th:checked="${xtStat.first}"
                           name="sjXtCheck" onvaluechanged="checkUn(this)"/>
                    <span th:class="${xt.checkResultCode!='1'?'fc_red':''}" th:text="${xt.showData}"></span>
                    <i th:if="${xt.checkResultCode=='3'}" class="fc_red fc-16">↑</i>
                    <i th:if="${xt.checkResultCode=='4'}" class="fc_red fc-16">↓</i>
                </td>
                <td th:text="${xt.measureTime}"></td>
                <td th:text="${#dic.yljgdm(xt.measureOrgId)}"></td>
                <td th:text="${xt.measureSourceName}"></td>
            </tr>