java类:
public class PopedomItem { private String id; private String pid; private String name; private String checked; private List<PopedomItem> children; }
页面代码:
<c:forEach items="${items}" var="item"> <tr id="${item.id}"> <td> <span class="folder">${item.name }</span> </td> <td> -- </td> <td> 备注说明 </td> </tr> <c:forEach items="${item.children}" var="it"> <tr id="${it.id}" class="child-of-${it.pid }"> <td> <span class="<c:if test="${!empty it.children }">folder</c:if><c:if test="${empty it.children }">file</c:if>">${it.name }</span> </td> <td> -- </td> <td> 备注说明 </td> </tr> <c:forEach items="${it.children}" var="i"> <tr id="${i.id}" class="child-of-${i.pid }"> <td> <span class="file">${i.name }</span> </td> <td> -- </td> <td> 备注说明 </td> </tr> </c:forEach> </c:forEach> </c:forEach>
提问者采纳
<span class="<c:if test="${!empty it.children }">folder</c:if><c:if test="${empty it.children }">file</c:if>">${it.name }</span>
可以改为
<c:choose> <c:when test="${!empty it.children }"> <c:set var="class" value="folder"/> </c:when> <c:otherwise> <c:set var="class" value="file"/> </c:otherwise> </c:choose> <span class="${class}">${it.name }</span>
原文:http://www.cnblogs.com/zhujiabin/p/5126714.html