经常用到以下代码遍历呈现后台返回来的List,特此Mark一下:
JSP页面头部引用JSTL标签:
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> <%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
JSP内容:
<c:if test="${tradeList==null || fn:length(tradeList) == 0}"> <tr> <td colspan="4">还没有人购买过该商品,快来抢购吧!</td> </tr> </c:if> <c:forEach items="${tradeList}" var="item" varStatus="status"> <tr > <td class="center"><span class="center">${item.trade_name}</span></td> <td><dfn>¥</dfn>${item.trade_price}</td> <td>${item.trade_count}</td> <td>${item.trade_time}</td> </tr> </c:forEach>
时间: 2024-10-29 04:36:37