JSTL标签+EL表达式遍历List内容

来源:互联网 发布:阿里云学生认证 高中生 编辑:程序博客网 时间:2024/05/16 08:16

经常用到以下代码遍历呈现后台返回来的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>




1 0
原创粉丝点击