📄 shopcar.jsp
字号:
<%@ page language="java" contentType="text/html; charset=gb2312"%>
<%@ page import="java.util.*"%>
<%@ page import="com.yxq.bean.SingleObject"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
java.util.Map<String,String> bmap=new java.util.HashMap<String,String>();
String buttonU="更新数量";
String buttonD="删除选中";
bmap.put(buttonU,"update");
bmap.put(buttonD,"delete");
session.setAttribute("bmap",bmap);
%>
<html>
<head>
<title>购物车</title>
<base href="<%=basePath%>">
<link rel="stylesheet" type="text/css" href="css/style.css">
</head>
<body>
<center>
<!-- 显示购物车 -->
<form action="shop/UorD" method="post">
<table border="1" width="730" cellspacing="0" bordercolor="#9A6601" bordercolorlight="#9A6601" bordercolordark="white" rules="rows">
<tr bgcolor="#DCCAA6"><td colspan="8" height="25" align="center">购买的商品</td>
<tr height="25">
<th align="center" width="8%">序号</th>
<th align="left" colspan="2">名称</th>
<th align="left" width="10%">单价</th>
<th align="left" width="10%">数量</th>
<th align="left" width="10%">总价</th>
<th align="center" width="10%">库存</th>
<th align="center" width="10%">删除</th>
</tr>
<tr>
<td colspan="8" align="center">
<table width="730" cellspacing="0">
<%
Map carmap=(HashMap)session.getAttribute("carmap");
if(carmap==null||carmap.size()==0){ %>
<tr bgcolor="#F4F1DE" height="150"><td align="center" colspan="8" background="image/buy/none.gif"><font color="#9A6700">友情提示!您的购物车为空!</font><a href="shop/preindex?mainPage=gobuy.jsp">[ 去购物 ]</a></td></tr>
</table>
<%
}else{
int i=0;
float payfor=0;
Collection c=carmap.values();
Iterator it=c.iterator();
while(it.hasNext()){
SingleObject carsingle=(SingleObject)it.next();
payfor+=carsingle.getBuyMoney();
if((i+2)%2==0){ %>
<tr height="30" bgcolor="#F4F1DE">
<% }else{ %>
<tr height="30" bgcolor="#EBE5C3">
<% } %>
<td align="center" width="8%"><%=i+1%></td>
<td width="30%" ><%=carsingle.getName()%></td>
<td align="center" width="12%"> <b><font color='red'><%=carsingle.getMessage()%></font></b></td>
<td width="10%"><%=carsingle.getPrice()%></td>
<td width="10%"><input type="text" name="car_number" value="<%=carsingle.getBuyN()%>" size="5" style="border:1 solid;text-align:center"></td>
<td width="10%"><%=carsingle.getBuyMoney()%></td>
<td align="center" width="10%"><%=carsingle.getHave()%></td>
<td align="center" width="10%"><input type="checkbox" name="car_selected" value="<%=carsingle.getId()%>"></td>
</tr>
<tr><td><input type="hidden" name="car_id" value=<%=carsingle.getId()%>></td></tr>
<% i++;
}//while
payfor=Math.round(payfor*100)/100f;
%>
</table>
</td>
</tr>
<tr>
<td colspan="8" height="20">
<marquee scrollamount="1" scrolldelay="1"><font color="#BF1613">30分钟内没有任何操作,请重新访问!</font></marquee>
</td>
</tr>
<tr height="25" bgcolor="#DCCAA6">
<td align="center" colspan="3"><a href="shop/preindex?mainPage=gobuy.jsp">[继续购物]</a></td>
<td align="center" colspan="5"><font color="#BF1613">应付金额:¥<%=payfor%></font></td>
</tr>
<tr height="30">
<td align="center" colspan="8" bgcolor="#EBE5C3">
<input type="hidden" name="mainPage" value="shopcar.jsp">
<input type="submit" name="op" value="<%=buttonU%>">
<a href="#">[收银台结算]</a>
<a href="shop/UorD?op=deleteAll&mainPage=shopcar.jsp">[购物车清空]</a>
<input type="submit" name="op" value="<%=buttonD%>">
</td>
</tr>
<% } %>
</table>
</form>
</center>
</body>
</html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -