当前位置: 代码迷 >> Java面试 >> :JSTL中的<c:foreach>遍历如何才能算出总销售-本金=总利润
  详细解决方案

:JSTL中的<c:foreach>遍历如何才能算出总销售-本金=总利润

热度:7080   发布时间:2013-02-25 21:23:34
求助:JSTL中的<c:foreach>遍历怎么才能算出总销售-本金=总利润

<c:forEach items = "${shopList}" var = "shop">
    <tr>
        <td>${shop.shopID}元</td>
<td>${shop.shopName}元</td>
<td>${shop.costPrice}元</td>
<td>${shop.flatPrice}元</td>
<td>${shop.flatPrice - shop.costPrice}元</td>
    </tr>
</c:forEach>
    <tr>
<td colspan="4" align="center">总利润</td>
<td>
???????---------------
</td>
    </tr>


图:

<c:set var="sum" value="0"/>
<c:forEach items = "${shopList}" var = "shop">
    <tr>
        <td>${shop.shopID}元</td>
    <td>${shop.shopName}元</td>
    <td>${shop.costPrice}元</td>
    <td>${shop.flatPrice}元</td>
    <td>${shop.flatPrice - shop.costPrice}元<c:set var="sum" value="${sum+shop.flatPrice - shop.costPrice}"/></td>
    </tr>
</c:forEach>
    <tr>
    <td colspan="4" align="center">总利润</td>
    <td>
    ${sum}
    </td>
    </tr>
  相关解决方案
本站暂不开放注册!
内测阶段只得通过邀请码进行注册!