<c:forEach items="${listrkl}" var="item"> <tr>
<td>${item.warehouse_name}</td>
<td>${item.total_string}</td>
<td>${item.price_string}</td>
<td>${item.totalMoney_String}</td>
<td>${item.standard}</td>
</tr>
</c:forEach>
上面的代碼循環是正確的,可以循環出數據,現在的需求是,判斷數是否是最后一條數據 或是 只有一條數據,如果是 tr添加類 class=“last”,不是的正常顯示
怎么來添加 if else 呢 ? 請指教,謝謝!
3 回答

犯罪嫌疑人X
TA貢獻2080條經驗 獲得超4個贊
c:forEach
有個varStatus
的屬性可以試試:
<c:forEach items="${listrkl}" var="item" varStatus="status">
<c:if test="${listrkl.size() == status.index - 1}">
...
</c:if>
</c:forEach>
我好久沒寫JSP了,可能EL寫得有問題,你可以調試一下。
添加回答
舉報
0/150
提交
取消