📄 bookstore.jsp
字号:
<%@ page contentType="text/html; charset=UTF-8" language="java" import="java.sql.*" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%@ page import="java.util.*" %>
<%@ include file="common.jsp" %>
<%@ page import="mypack.*" %>
<%@ page session="true" %>
<jsp:useBean id="cart" scope="session" class="mypack.ShoppingCart"/>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>bookstore</title>
<style type="text/css">
<!--
@import url("common.css");
-->
</style>
</head>
<%@ include file="banner.jsp" %>
<table width="1023" border="0" cellpadding="0" cellspacing="0">
<!--DWLayoutTable-->
<tr>
<td width="278" height="48" valign="top"><table width="100%" border="0" cellpadding="0" cellspacing="0">
<!--DWLayoutTable-->
<tr>
<td>
<%
if (session.getAttribute("user") != null) {
Customer user = (Customer) session.getAttribute("user");
String username = user.getUserName();
%>
<strong><a> 欢迎,<%=username%>! </a></strong>
<%
}
%>
</td>
</tr>
</table> </td>
<td width="745" valign="top"><table width="100%" border="0" cellpadding="0" cellspacing="0">
<!--DWLayoutTable-->
<tr>
<td width="500" height="64" align="center" valign="top">
<h3><a href="booksSort.jsp"><font color="green">书籍排行榜</font></a></h3>
</td>
<td width="745" height="64" align="center" valign="top">
<form action=bookdetails.jsp method="POST">
<select name="select" id="select">
<option value="1">编号</option>
<option value="2">书名</option>
<option value="3">作者</option>
</select>
<input type="text" size="20" name="message" value="" >
<input type=submit value="搜">
</form>
</td>
</tr>
</table>
</td>
</tr>
</table>
<table width="1023" border="0" cellpadding="0" cellspacing="0">
<!--DWLayoutTable-->
<tr>
<td width="229" height="292" valign="top">
<table width="1023" border="0" cellpadding="0" cellspacing="0">
<!--DWLayoutTable-->
<tr>
<td width="229" height="256" valign="top"><table width="100%" border="0" cellpadding="0" cellspacing="0">
<!--DWLayoutTable-->
<tr>
<td width="229" height="91" valign="top"><table width="100%" border="0" cellpadding="0" cellspacing="0" class="panel">
<!--DWLayoutTable-->
<tr>
<td><strong><h3><font color="green">分类浏览</font></h3></strong></td>
</tr>
<%
request.setCharacterEncoding("UTF-8");
String btid = null;
String btname = null;
Collection c = bookDB.getBookTypeSet();
Iterator i = c.iterator();
while (i.hasNext()) {
Booktype bt = (Booktype) i.next();
btid = bt.getId();
btname = btid + "";
%>
<tr>
<td bgcolor="#ffffaa">
<a href="<%=request.getContextPath()%>/bookstore.jsp?btname=<%=btname%>" target="_self"><strong>
<%=convert(bt.getName())%> </strong></a></td>
</tr>
<% }%><!--DWLayoutEmptyCell-->
</table>
</td>
</tr>
<tr>
<td height="165"> </td>
</tr>
</table> </td>
<td width="794" valign="top"><table width="100%" border="0" cellpadding="0" cellspacing="0">
<!--DWLayoutTable-->
<tr>
<td width="53" height="410"> </td>
<td width="741" valign="top"><%
// Additions to the shopping cart
String bookId = request.getParameter("Add");
if (bookId != null) {
BookDetails book = bookDB.getBookDetails(bookId);
cart.add(bookId, book);
%>
<p>
<h3>
<font color="red">
您已将 <i><%=convert(book.getTitle())%></i> 加入购物车</font></h3>
<%
}
if (cart.getNumberOfItems() > 0) {
%>
<p><strong><a href="<%=request.getContextPath()%>/showcart.jsp?user=<%=session.getAttribute("user")%>" target="_self">察看购物车</a>
<a href="<%=request.getContextPath()%>/cashier.jsp" target="_self">付账</a></p>
</strong>
<%
}
%>
<h3><font color="green">请选择想购买的书:</font></h3> <table>
<!--DWLayoutTable-->
<%
request.setCharacterEncoding("UTF-8");
btname = request.getParameter("btname");
if (btname == null) {
Collection cc=bookDB.getBooks();
Iterator ii=cc.iterator();
while(ii.hasNext()){
BookDetails book=(BookDetails)ii.next();
bookId=book.getBookId();
%>
<tr>
<td width="244" height="26" valign="top" bgcolor="#ffffaa">
<a href="<%=request.getContextPath()%>/bookdetails.jsp?bookId=<%=bookId%>" target="_self"><strong>
<%=convert(book.getTitle())%> </strong></a></td>
</tr>
<tr>
<td height="26" valign="top" bgcolor="#ffffff"> 作者:<em><%=convert(book.getName())%></em>
</tr>
<td bgcolor="#ffffaa" rowspan=1>
<a href="<%=request.getContextPath()%>/bookstore.jsp?Add=<%=bookId%>" target="_self"> 加入购物车 </a></td>
<%}
}else{
Booktype bt = bookDB.getBooktype(btname);
i = bt.getBookDetails().iterator();
while (i.hasNext()) {
BookDetails book = (BookDetails) i.next();
bookId = book.getBookId();
// javax.swing.JOptionPane.showMessageDialog(null, book.getName());
%>
<tr>
<td width="244" height="26" valign="top" bgcolor="#ffffaa">
<a href="<%=request.getContextPath()%>/bookdetails.jsp?bookId=<%=bookId%>" target="_self"><strong>
<%=convert(book.getTitle())%> </strong></a></td>
</tr>
<tr>
<td height="26" valign="top" bgcolor="#ffffff"> 作者:<em><%=convert(book.getName())%></em>
</tr>
<td bgcolor="#ffffaa" rowspan=1>
<a href="<%=request.getContextPath()%>/bookstore.jsp?Add=<%=bookId%>" target="_self"> 加入购物车 </a></td>
<% }}%>
</table></td>
</tr>
</table>
</td>
</tr>
</table>
</body>
</html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -