?? showcart.jsp
字號:
<%@ page contentType="text/html; charset=GB2312" %>
<%@ page import="java.util.*" %>
<jsp:useBean id="cart" scope="session" class="mypack.ShoppingCart"/>
<html>
<head><title>LIVE在線書店-購書</title>
<style type="text/css">
<!--
.STYLE33 {
color: #0066FF;
font-weight: bold;
font-size: 16px;
}
-->
</style>
</head>
<%@ include file="logo3.jsp" %>
<%
if(name==null)
{
out.println("<script>alert('您還沒有登陸!');" +
"location.href='login.jsp'</script>");
}
else
{
%>
<%
String bookId = request.getParameter("Remove");
if (bookId != null) {
cart.remove(bookId);
BookDetails book = bookDB.getBookDetails(bookId);
%>
<font class="STYLE3">您刪除了一本書:<%=convert(book.getTitle())%>
<br> <br>
</font>
<%
}
if (request.getParameter("Clear") != null) {
cart.clear();
%>
<font color="red" size="+2"><strong>
清空購物車
</strong><br> <br></font>
<%
}
int num = cart.getNumberOfItems();
if (num > 0) {
%>
<font class="STYLE33"> 您的購物車內有<%=num%>本書
</font><br>
<table>
<%
Iterator i = cart.getItems().iterator();
while (i.hasNext())
{
ShoppingCartItem item = (ShoppingCartItem)i.next();
BookDetails book = (BookDetails)item.getItem();
%>
<table width="800" border="0" cellspacing="0" cellpadding="0" align="center">
<tr>
<td width="120" rowspan="10" align="left" valign="top"><a href="<%=request.getContextPath()%>/bookdetails.jsp?bookId=<%=book.getBookId()%>"><img src="images/<%=book.getBookId()%>.jpg" width="80" height="90" border="0" ></a></td>
<td width="500">
<strong><a href="<%=request.getContextPath()%>/bookdetails.jsp?bookId=<%=book.getBookId()%>">
<%=convert(book.getTitle())%></a></strong>
</td>
</tr>
<tr>
<td>作者 :<b><%=book.getName()%></b>
</td>
</tr>
<tr>
<td>市場價:<b><%=book.getPrice()%></b>元
</td>
</tr>
<tr>
<td>
數量:<%=item.getQuantity()%>
</td>
</tr>
<tr>
<td>
<strong>
<a href="<%=request.getContextPath()%>/showcart.jsp?Remove=<%=book.getBookId()%>">刪除</a></strong>
</td>
</tr>
</table>
<br>
<%
}
%>
<tr><td colspan="5" bgcolor="#ffffff"><br></td></tr>
<tr>
<td colspan="2" align="right" bgcolor="#ffffff"> 總計:</td>
<td bgcolor="#ffffaa" align="right"><b><%=cart.getTotal()%>元</b></td>
<td><br></td>
</tr>
</table>
<strong><a href="<%=request.getContextPath()%>/catalog.jsp"> 繼續購物</a>
<a href="<%=request.getContextPath()%>/cashier.jsp">付賬</a>
<a href="<%=request.getContextPath()%>/showcart.jsp?Clear=clear">清空購物車</a></strong>
<%
} else {
%>
<font class="STYLE33" >您的購物車目前為空</font>
<br> <br>
<a href="<%=request.getContextPath()%>/catalog.jsp">繼續購物</a>
<%
}
%>
<%
}
%>
</body>
</html>
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -