개발_웹/Java

JSP | JSTL <c:set>을 이용해서 총합 계산하기

zuyo 2019. 5. 11. 01:05
반응형
…
<c:forEach items="${products }" var="product">
    <input type="hidden" name="name" value="${product.name }">
    <input type="hidden" name="price" value="${product.price }">
    <tr>
        <td>${product.name }</td>
        <td class="text-right">${product.price }원</td>
    </tr>
    <c:set var="total" value="${total + product.price }" />
</c:forEach>
</tbody>
</table>

<div class="total-amount">
    <c:out value="주문금액 : ${total }원"></c:out>
</div>

 

반응형