2024-12-19



<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%-- JSTL 라이브러리를 사용하겠다고 선언 --%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%-- 포멧팅 라이브러리를 사용하겠다고 선언 --%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
<c:set var="coffee" value="${ param.coffee_str }"/>
<c:set var="amount" value="${ param.amount }"/>
<c:choose>
<c:when test="${ coffee == 1 }">
<c:set var="coffeeStr" value="아메리카노"/>
<c:set var="price" value="3000"/>
</c:when>
<c:when test="${ coffee == 2 }">
<c:set var="coffeeStr" value="카페라떼"/>
<c:set var="price" value="4000"/>
</c:when>
<c:when test="${ coffee == 3 }">
<c:set var="coffeeStr" value="카푸치노"/>
<c:set var="price" value="4500"/>
</c:when>
<c:when test="${ coffee == 4 }">
<c:set var="coffeeStr" value="마끼아또"/>
<c:set var="price" value="4500"/>
</c:when>
</c:choose>
<div align="center">
<h2>커피 주문 내역</h2>
<table border="1" width="350">
<tr>
<th>커피 종류</th>
<td>${ coffeeStr }</td>
</tr>
<tr>
<th>커피 단가</th>
<td><fmt:formatNumber value="${ price }"/> 원</td>
</tr>
<tr>
<th>커피 수량</th>
<td>${ amount } 개</td>
</tr>
<tr>
<th>공급가액</th>
<td><fmt:formatNumber value="${ price * amount }"/> 원</td>
</tr>
<tr>
<th>부가세액</th>
<td><fmt:formatNumber value="${ (price * amount) * 0.1 }"/> 원</td>
</tr>
<tr>
<th>총금액</th>
<td><fmt:formatNumber value="${ (price * amount) + ((price * amount) * 0.1) }"/> 원</td>
</tr>
</table>
</div>
</body>
</html>'JSP > 기초 내용 정리' 카테고리의 다른 글
| Java(Example)_MEMBER2 (0) | 2024.12.23 |
|---|---|
| JSP(JSTL)_04 (1) | 2024.12.19 |
| JSP(JSTL)_02 (0) | 2024.12.19 |
| JSP(JSTL)_01 (0) | 2024.12.19 |
| JSP(JSTL)_00 (0) | 2024.12.19 |