日期:2014-05-16  浏览次数:20385 次

jsp学习笔记(21)
bookList.jsp代码如下:
	<%@ page language="java" contentType="text/html; charset=gb2312"
	pageEncoding="gb2312"%>
	<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" 	"http://www.w3.org/TR/html4/loose.dtd">
	<%@page import="java.util.ArrayList"%><html>
	<head>
	<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
	<title>网上书店</title>
	<link href="../css/style.css" rel="stylesheet" type="text/css" />
	<link type="text/css" rel="stylesheet" href="../jquery/jquery_dialog.css" />
	<script type="text/javascript" src="../jquery/jquery.js"></script>
	<script type="text/javascript" src="../jquery/jquery_dialog.js"></script>
	</head>
	<body>
	<div id="container">
		<%@include file="header.jsp" %>
	<div id="header">
	<div id="special_offers"></div>
	<div id="new_books"></div>
	</div>
	<div id="content">
	<%@include file="left.jsp" %>
	<div id="content_right">
	<h1>图书列表</h1>
		<div class="image_panel"><form action="" method="post">
		<table width="656" height="46" border="1" bordercolor="#996600">
		<tr>
			<td width="127">商品名称</td>
			<td width="129">作者</td>
			<td width="91">出版社</td>
			<td width="86">价格</td>
			<td width="86">ISBN</td>
			<td width="97">购买</td>
		</tr>
			<%
				ArrayList bookSearch = (ArrayList)request.getAttribute("search");
				ArrayList alRow = null; 
				if(bookSearch != null){
					for(int i = 0;i < bookSearch.size();i++){
					 alRow = (ArrayList)bookSearch.get(i);
			%>
		<tr>
			<td><a href="/OnlineShop/servlet/BookinfServlet?bookId=<%=alRow.get(0)%>" 
			title="点击查看详细信息"><%=alRow.get(1)%></a></td>
			<td><%=alRow.get(2) %></td>
			<td><%=alRow.get(3) %></td>
			<td><%=alRow.get(5) %></td>
			<td><%=alRow.get(4) %></td>
			<td>
			<div class="buy_now_button"><a href="#"onclick="JqueryDialog.Open('购物车
			','/OnlineShop/servlet/ShoppingServlet?method=add&bookId=
			<%=alRow.get(0)%>&bookName=<%=alRow.get(1) %>&bookQuantity
			=1&bookPrice=<%=alRow.get(5) %>', 630, 300);">购买</a></div>
			</td>
		</tr>
		<%}} %>
		</table>
		</form></div>
		<% 
			Integer currentPage = (Integer)request.getAttribute("currentPage");
			Integer pageCount   = (Integer)request.getAttribute("pageCount");
			if(currentPage==null || pageCount==null){
				currentPage = 0;
				pageCount = 0;
			}
		%>
		<table width="656" border="0">
			<tr align="center">
			<td width="206">第<%=currentPage %>页</td>
			<td width="45"><a href="/OnlineShop/servlet/PageServlet?page=1">首页
			</a></td>
			<td width="45"><a href="/OnlineShop/servlet/PageServlet?page=<%=
			currentPage-1 %>">上一页</a></td>
			<td width="45"><a href="/OnlineShop/servlet/PageServlet?page=
			<%=currentPage+1 %>">下一页</a></td>
			<td width="45"><a href="/OnlineShop/servlet/PageServlet?page=
			<%=pageCount %>">末页</a></td>
			<td width="230">共<%=pageCount %>页</td>
			</tr>
		</table>
		<h2>&nbsp;</h2>
		<div class="cleaner_with_height">&nbsp;</div>
		<a href="#"><img src="../images/ads_cn.jpg"  /></a> </div>
	<div id="footer"> 
		Copyright &copy; 2010<strong>NIT</strong>| Designed by NIT </div>
	</div>
	</body>
	</html>