⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 viewcart.jsp

📁 jsp/serlvet/javaBean:订餐系统
💻 JSP
字号:
<%@ page language="java" session="true" pageEncoding="GBK"%>
<%@ page import="java.util.*,bean.*,java.text.*"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
	<head>
		<base href="<%=basePath%>">

		<title>餐品购物车</title>

		<meta http-equiv="pragma" content="no-cache">
		<meta http-equiv="cache-control" content="no-cache">
		<meta http-equiv="expires" content="0">
		<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
		<meta http-equiv="description" content="This is my page">
		<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->

	</head>

	<body>
		<table align="center">
			<tr>
				<td>
					<%
						Map cart = (Map) session.getAttribute("cart");

						if (cart == null || cart.size() == 0) {
							out.println("<p>购物车当前为空</p>");
						} else {
					%>
					<table border="1" align="center">
						<thead>
							<tr align="center">
								<th>
									名称
								</th>
								<th>
									数量
								</th>
								<th>
									价格
								</th>
								<th>
									小计
								</th>
							</tr>
						</thead>
						<%
								Set cartItems = cart.keySet();
								Object[] foodID = cartItems.toArray();
								double total = 0, subtotal;
								float price;
								int quantity;
								for (int i = 0; i < foodID.length; i++) {
									CartItemBean cartBean = (CartItemBean) cart
									.get((Integer) foodID[i]);
									FoodBean food = cartBean.getFood();
									quantity = cartBean.getQuantity();
									price = food.getFoodPrice();
									subtotal = price * quantity;
									total += subtotal;
						%>
						<tr>
							<td>
								<%=food.getFoodName()%>
							</td>
							<td>
								<%=quantity%>
							</td>
							<td>
								<%=new DecimalFormat("0.00").format(price)%>
							</td>
							<td>
								<%=new DecimalFormat("0.00").format(subtotal)%>
							</td>
						</tr>
						<%
						}
						%>
						<tr>
							<td colspan="4" align="right">
								<b>总计:</b>
								<%=new DecimalFormat("0.00").format(total)%>
							</td>
						</tr>
					</table>
					<%
						session.setAttribute("total", new Double(total));
						}
					%>
					<p>
						<a href="chJsp/show.jsp" target="mainFrame">继续订餐</a>
					</p>
					<form method="get" action="chJsp/order.jsp" target="mainFrame">
						<p>
							<input type="submit" value="结  帐">
						</p>
					</form>
				</td>
			</tr>
		</table>
	</body>
</html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -