JSP(JSTL)_03

2024. 12. 19. 18:44·JSP/기초 내용 정리

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
'JSP/기초 내용 정리' 카테고리의 다른 글
  • Java(Example)_MEMBER2
  • JSP(JSTL)_04
  • JSP(JSTL)_02
  • JSP(JSTL)_01
mw41817
mw41817
일생의 개발 기록 저장소
  • mw41817
    IT 개발 일지
    mw41817
    • Index (487)
      • HTML (36)
        • 기초 내용 정리 (36)
      • CSS (29)
        • 기초 내용 정리 (29)
      • JavaScript (60)
        • 기초 내용 정리 (60)
      • JQuery (38)
        • 기초 내용 정리 (38)
      • Java (232)
        • 기초 내용 정리 (232)
      • JSP (46)
        • 기초 내용 정리 (46)
      • Spring, Boot (31)
        • 기초 내용 정리 (31)
      • DB (5)
        • Oracle SQL (5)
      • Code WorkBook (6)
        • programmers (6)
        • Baekjoon (0)
      • 기타 (1)
        • 유용한 사이트 (3)
  • 전체
    오늘
    어제
  • 글쓰기 관리
  • 블로그 메뉴

    • 홈
    • 태그
    • 방명록
    • 카테고리
    • 주인장 GitHub
  • 공지사항

  • 인기 글

  • 태그

    html #코딩 #프로그래밍 #기초
  • 최근 댓글

  • hELLO· Designed By정상우.v4.10.0
mw41817
JSP(JSTL)_03
상단으로

티스토리툴바