📄 buy.jsp
字号:
<%@ page language="java" import="java.util.*" pageEncoding="gbk"%>
<%@ page import="conn.*, bean.*" %>
<%
Cart c = (Cart)session.getAttribute("cart");
if(c == null) {
c = new Cart();
session.setAttribute("cart", c);
}
%>
<%
request.setCharacterEncoding("GBK");
String action = request.getParameter("action");
if(action != null && action.trim().equals("add")) {
String bookid = request.getParameter("goodID");
String sql="select *from goods where bookid='"+bookid+"'";
GoodsDao use=new GoodsDao();
Goods p=new Goods();
p =(Goods)use.goodsSelect(sql).get(0);
CartItem ci = new CartItem();
ci.setBook(p);
ci.setCount(1);
c.add(ci);
}
if(action != null && action.trim().equals("delete")) {
int id = Integer.parseInt(request.getParameter("id"));
c.deleteItemById(id);
}
if(action != null && action.trim().equals("update")) {
for(int i=0; i<c.getItems().size(); i++) {
CartItem ci = c.getItems().get(i);
int count = Integer.parseInt(request.getParameter("p" + ci.getBook().getBookid()));
ci.setCount(count);
}
}
%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<%
List<CartItem> items = c.getItems();
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=GB18030">
<title>购物车</title>
<script language="javascript">
function butto(){
document.forms[0].submit();
}
</script>
<link href="css/style1.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div class="shopping_top">
<a href="frame.htm"><IMG src="temp.files/logo.gif" border=0 /></a>
<div class="now_notice">[购物车]</div>
</div>
<div class="my_shopping"><Iid=IMG1 alt="我的购物车" src="temp.files/shopcar.jpg" border=0 name=IMG1><div id="free_fee_tip" class="shop_news t_red"><a name='free_tip' href='http://static.dangdang.com/topic/744/200855/8634.shtml' target='_blank'>全场30元以上免运费,30元以下5元运费</a></div>
</div>
<div class="new_notice">通知:按照相关部门指示,为确保奥运期间运输环节的安全,部分商品,机电装置产品、电池、类似肥皂块状、膏状、类似面粉、化肥等粉末状物品(含化工类产品)不明金属、装有各种气体的密闭装置、各种液体产品(化妆品、洗发水、沐浴露类生活用品),<span class="c_red">于2008年6月5日始,将不能通过普通邮递、EMS方式进行配送</span>,给您带来的不便敬请谅解!
</div>
<form action="Buy.jsp" method="get">
<input type="hidden" name="action" value="update"/>
<table align="center" border="1" width=956px>
<tr style="border:solid 1pt">
<td>产品ID</td>
<td>产品名称</td>
<td>购买数量</td>
<td>单价</td>
<td>总价</td>
<td>处理</td>
</tr>
<%
for(Iterator<CartItem> it = items.iterator(); it.hasNext(); ) {
CartItem ci = it.next();
%>
<tr style="border: solid 1pt">
<td style="border: solid 1pt"><%=ci.getBook().getBookid() %></td>
<td style="border: solid 1pt"><%=ci.getBook().getBookname() %></td>
<td style="border: solid 1pt">
<input type="text" onblur=butto() size=3 name="<%="p" + ci.getBook().getBookid() %>" value="<%=ci.getCount() %>">
</td>
<td style="border: solid 1pt"><%=ci.getBook().getPrice() %></td>
<td style="border: solid 1pt"><%=ci.getBook().getPrice()*ci.getCount() %></td>
<td style="border: solid 1pt">
<a href="Buy.jsp?action=delete&id=<%=ci.getBook().getBookid() %>">删除</a>
</td>
</tr>
<%
}
%>
<tr style="border:solid 1pt">
<td colspan=3 style="border: solid 1pt"><a href="frame.htm">返回继续浏览>></a></td>
<td colspan=2 style="border: solid 1pt" align=right>总价:<%=c.getTotalMemberPrice() %></td><td>
<a href="CommitOrder.jsp">下单</a>
</td>
</tr>
</table>
</form>
<div class="shop_other">
<p> * 您购物车中的商品信息,我们将为您保存30天,请您及时购买。购物车中显示的价格为商品的最新价格。</p>
<p> * 您对购物车满意么?请您留下宝贵建议,欢迎您下次光临。</p>
</div>
<table align=center> <td> <DIV class=booksbot-text >
<UL>
<LI> 客服电话:********** (工作时间:****************)
<LI style="PADDING-LEFT: 95px">
010-82389225 (工作时间:********;*******)
<LI>
传真:******** 客户服务E-mail
<A href="mailto:bookschina804@vip.sina.com"></A>
<LI>
<A href="http://www.miibeian.gov.cn/" target=_blank>经营许可证编号:*********</A>
<A href="http://www.bookschina.com/include/type2.asp"
target=_blank>***监发******</A>
<LI>
<A href="http://www.ectrustprc.org.cn/seal/splash/1000006.htm"
target=_blank><IMG
src="temp.files/ectrust.gif">
</A>
<A
href="http://www.hd315.gov.cn/beian/view.asp?bianhao=010202002042800018"
target=_blank><IMG height=48
src="temp.files/biaoshi.gif" width=40>
</A>
<A href="http://www.315online.com.cn/member/315070139.html"
target=_blank><IMG
src="temp.files/315online.gif">
</A>
</LI>
</UL>
</DIV></td></table>
</body>
</html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -