<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ page import="com.jc.bookshop.bing.entity.Books" %>
<%@ page import="com.jc.bookshop.bing.entity.Categories"%>
<%@ page import="com.jc.bookshop.bing.entity.Publishers" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<jsp:useBean id="booklogic" class="com.jc.bookshop.bing.logic.BooksLogic" scope="page"></jsp:useBean>
<jsp:useBean id="catelogic" class="com.jc.bookshop.bing.logic.CategoriesLogic" scope="page"></jsp:useBean>
<jsp:useBean id="publogic" class="com.jc.bookshop.bing.logic.PublisherLogic" scope="page"></jsp:useBean>
<html>
<head>
<base href="<%=basePath%>">
<title>My JSP 'BookShow.jsp' starting page</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->
<link rel="stylesheet" type="text/css" href="CSS/MyCss.css">
<link rel="stylesheet" type="text/css" href="CSS/book_list.css">
<script language="javascript" type="text/javascript">
function clearbookname()
{
document.getElementById('txtbookname').value=" ";
document.getElementById('txtbookname').style.color="#000000";
}
function sousuo()
{
var bookname=document.getElementById('txtbookname').value;
if(bookname==" ")
{
alert("请输入图书关键字");
return;
}
document.sousuofrom.submit();
}
</script>
</head>
<body background="Images/8.jpg">
<table width="866" border="0" align="center" cellpadding="0" cellspacing="0" style="border:1px solid #000099;" bgcolor="#FFFFFF">
<tr>
<td width="855"> <jsp:include flush="true" page="Head.jsp"></jsp:include></td>
</tr>
<tr>
<td height="5"></td>
</tr>
<tr>
<td height="35"> <jsp:include flush="true" page="Title.jsp"></jsp:include></td>
</tr>
<tr>
<td height="400"><table width="838" border="0" cellpadding="0" cellspacing="0">
<tr>
<td bgcolor="#E4E9FA" valign="top"><table width="202" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="201" height="29" background="Images/a11.gif" class="font"> <img src="Images/smallbook.jpg" width="10" height="10"> 图书搜索</td>
</tr>
<tr>
<td height="100">
<form action="Search.jsp" method="post" name="sousuofrom">
<table width="200" height="80" border="0" cellpadding="0" cellspacing="0">
<tr>
<td height="37" align="center"><img src="Images/unExactQuery.gif"/><input type="text" id="txtbookname" name="bookname" size="20" onClick="clearbookname()" value="请输入图书名称关键字" style="color:#CCCCCC;"></td>
</tr>
<tr>
<td align="center"><input type="button" name="but" value="搜索" onClick="sousuo()"> <a href="Advanced.jsp">【高级搜索】</a></td>
</tr>
</table>
</form>
</td>
</tr>
</table>
<table width="203" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="203" height="31" background="Images/a11.gif" class="font"> <img src="Images/smallbook.jpg" width="10" height="10"> 图书分类</td>
</tr>
<tr>
<td height="100" valign="top" align="center">
<table width="145" border="0" cellpadding="0" cellspacing="0">
<%
for(ListIterator iter=catelogic.GetAllCategories().listIterator();iter.hasNext();)
{
Categories cate =(Categories)iter.next();
%>
<tr>
<td width="170" align="left" class="font"><img src="Images/gif-0775.gif"> <a href="Sort.jsp?cateid=<%=cate.getId() %>" class="font"><%=cate.getName() %></a></td>
</tr>
<%
}
%>
</table>
</td>
</tr>
</table>
<table width="202" border="0" cellpadding="0" cellspacing="0">
<tr>
<td height="30" background="Images/a11.gif" class="font"> <img src="Images/smallbook.jpg" width="10" height="10"> 出版社排行榜</td>
</tr>
<tr>
<td height="100" align="center" valign="top">
<table width="145" border="0" cellpadding="0" cellspacing="0">
<%
for(ListIterator iter=publogic.GetAllPublisher().listIterator();iter.hasNext();)
{
Publishers pub=(Publishers)iter.next();
%>
<tr>
<td width="145"><img src="Images/gif-0775.gif"> <a href="Publisher.jsp?id=<%=pub.getId() %>" class="font"><%=pub.getName() %></a></td>
</tr>
<%
}
%>
</table>
</td>
</tr>
</table>
</td>
<td width="5" height="389" background="Images/yy.jpg"> </td>
<td valign="top"><table width="657" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="657" height="28" background="Images/a11.gif" class="font"> <img src="Images/smallbook.jpg" width="10" height="10"> 图书展示</td>
</tr>
<tr>
<td height="19" class="font" style="border-bottom:1px solid #cccccc; ">
<%!
int intpagesize=8;//每页显示的记录数
int intpagetotal;//总页数
int currpagebegin;//起始记录索引
int intpage;//要显示的页数
String strpage;//用户请求的页数
int count;//有多少条记录
%>
<%
List list=null;
list=booklogic.GetAllBooks();
count=list.size();//计算出有多少条记录
intpagetotal=count%intpagesize==0?count/intpagesize:count/intpagesize+1;//计算出总页数
strpage=request.getParameter("pagenumber");
if(strpage==null)
{
intpage=1;
}
else
{
intpage=Integer.parseInt(strpage);
if(intpage<1)
{
intpage=1;
}
}
if(intpage>intpagetotal)
{
intpage=intpagetotal;
}
currpagebegin=intpage*intpagesize-intpagesize;
%>
<table width="658" height="23" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="549" height="23" class="font">
</td>
<td width="72" class="font"> 共<%=count %>条记录</td>
</tr>
</table>
</td>
</tr>
<tr>
<td height="512" valign="top">
<%
for(int i=currpagebegin;i<intpage*intpagesize && i<count;i++)
{
Books book=(Books)list.get(i);
%>
<table width="658" border="0" cellpadding="0" cellspacing="0" style="border-bottom:1px dashed #cccccc; ">
<tr>
<td width="104" height="150" rowspan="4"><a href="BookDetail.jsp?id=<%=book.getId() %>"><img src="<%=book.getImage().getImagePath() %>" width="80" height="120" border="0"/></a></td>
<td width="415" class="font">书名:<a href="BookDetail.jsp?id=<%=book.getId() %>" ><%=book.getTitle() %></a></td>
<td width="139"> </td>
</tr>