📄 search.jsp
字号:
<%@ page contentType="text/html; charset=gb2312" language="java" import="java.sql.*" errorPage="" %>
<%@ page import="data.LoginData"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
<style type="text/html">
<!--
.STYLE1 {font-size: 9px}
-->
</style>
<style type="text/css">
<!--
.STYLE2 {
font-size: 24px;
font-weight: bold;
}
.STYLE3 {
font-size: 14px;
font-weight: bold;
color: #3399FF;
}
.STYLE4 {
font-family: "宋体";
font-weight: bold;
}
.STYLE6 {color: #3399FF}
.STYLE9 {font-size: 24px; font-weight: bold; color: #3399FF; }
.STYLE10 {font-size: 24px; font-weight: bold; color: #000000; }
.STYLE11 {font-size: 24px; font-weight: bold; color: #FFFFFF; }
.STYLE14 {font-size: 14px}
-->
</style>
</head>
<body>
<jsp:useBean id="show" class="Bean.MachSearch" scope="page">
</jsp:useBean>
<jsp:useBean id="connDbBean" scope="page" class="db.dbConn"/>
<%
Connection conn=null;
Statement stmt=null;
ResultSet rs=null;
String strSql="";
String strSql1="";
int PageSize=15;
int Page=1;
int totalPage=1;
int totalrecord=0;
int totalrecord1=0;
%>
<table width="100%" border="0" cellpadding="0" cellspacing="0" bordercolor="#333399">
<!--DWLayoutTable-->
<tr>
<td width="100%" height="76" valign="top"><table width="100%" border="0" cellpadding="0" cellspacing="0">
<!--DWLayoutTable-->
<tr>
<td width="171" rowspan="2" valign="top"><table width="100%" border="0" cellpadding="0" cellspacing="0">
<!--DWLayoutTable-->
<tr>
<td width="171" height="76" valign="middle"><img src="image/tushu2.bmp" /></td>
</tr>
</table> </td>
<td width="75" height="28"> </td>
<td width="100"> </td>
<td width="18"> </td>
<td width="101"> </td>
<td width="26"> </td>
<td width="100"> </td>
<td width="30"> </td>
<td width="100"> </td>
<td width="49"> </td>
<td width="100"> </td>
<td width="105"> </td>
</tr>
<tr>
<td height="48"> </td>
<td valign="top"><table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
<!--DWLayoutTable-->
<tr>
<td width="100" height="48" align="center" valign="bottom" bgcolor="#3366CC"><a href="Search.jsp" class="STYLE11">图书检索</a></td>
</tr>
</table></td>
<td> </td>
<td valign="top"><table width="100%" border="0" cellpadding="0" cellspacing="0">
<!--DWLayoutTable-->
<tr>
<td width="100" height="48" align="center" valign="bottom" bgcolor="#F5F5F5"><a href="Mylibary.jsp" class="STYLE10">我的图书</a></td>
</tr>
</table></td>
<td> </td>
<td valign="top"><table width="100%" border="0" cellpadding="0" cellspacing="0">
<!--DWLayoutTable-->
<tr>
<td width="100" height="48" align="center" valign="bottom" bgcolor="#F5F5F5"><a href="studentIndex.jsp" class="STYLE10">新书通报</a></td>
</tr>
</table></td>
<td> </td>
<td valign="top"><table width="100%" border="0" cellpadding="0" cellspacing="0">
<!--DWLayoutTable-->
<tr>
<td width="100" height="48" align="center" valign="bottom" bgcolor="#F5F5F5" class="STYLE9"><a href="ShowInfor.jsp" class="STYLE10">信息发布</a></td>
</tr>
</table></td>
<td> </td>
<td valign="top"><table width="100%" border="0" cellpadding="0" cellspacing="0">
<!--DWLayoutTable-->
<tr>
<td width="100" height="48" align="center" valign="bottom"><!--DWLayoutEmptyCell--> </td>
</tr>
</table></td>
<td> </td>
</tr>
</table></td>
</tr>
<tr>
<td height="30" valign="top"><table width="100%" border="0" cellpadding="0" cellspacing="0">
<!--DWLayoutTable-->
<tr>
<td width="975" height="30" bgcolor="#3366CC"> </td>
</tr>
</table> </td>
</tr>
<tr>
<td height="97" valign="top"><table width="100%" border="0" cellpadding="0" cellspacing="0" bordercolor="#FFFFFF" bgcolor="#F5F5F5">
<!--DWLayoutTable-->
<tr>
<td width="975" height="40"> </td>
</tr>
<tr>
<td height="30" valign="top"><table width="100%" border="0" cellpadding="0" cellspacing="0">
<!--DWLayoutTable-->
<tr>
<td width="125" height="57"> </td>
<td width="617" valign="bottom"><form id="form1" name="form1" method="post" action="Search.jsp">
<p>
<select name="select" class="STYLE3">
<option value="1">图书名</option>
<option value="2">图书编号</option>
<option value="3">主编</option>
<option value="4">出版社</option>
<option value="5">出版日期</option>
</select>
<input name="textfield" type="text" class="STYLE3" />
<input name="Submit" type="submit" class="STYLE3" value="提交" />
</p>
<p>
<span class="STYLE14">精确查找 </span>
<input name="radiobutton" type="radio" value="1" />
<label>
模糊查找<input name="radiobutton" type="radio" value="2" />
</label>
</p>
</form> <h3> </h3></td>
<td width="233"> </td>
</tr>
</table> </td>
</tr>
</table></td>
</tr>
<tr bordercolor="#003399">
<td height="179" align="center" valign="middle"><table width="100%" height="177" border="0"><!--DWLayoutTable-->
<tr>
<td width="100%" height="15"><div align="left" class="STYLE4">
<p class="STYLE6">搜索结果</p>
</div></td>
</tr>
<tr>
<td align="center" valign="baseline"><span class="STYLE2"><strong>
<%
String selectKid =(String)request.getParameter("select");
String infoKid = (String)request.getParameter("textfield");
String radioKid=(String)request.getParameter("radiobutton");
if(infoKid!=null){
byte b[]=infoKid.getBytes("ISO-8859-1");
infoKid=new String(b);
}
if((infoKid!="")&&(infoKid!=null)&&(radioKid!=null))
{
if(selectKid.equals("1")){
if(radioKid.equals("1")){
strSql="select * from Book where Bname ='"+infoKid +"'";
strSql1 = "SELECT count(*) as recordcount FROM Book where Bname ='"+infoKid +"'";
}
else if(radioKid.equals("2")){
strSql="select * from Book where Bname like'%"+infoKid +"%'";
strSql1 = "SELECT count(*) as recordcount FROM Book where Bname like'%"+infoKid +"%'";
}
}
else if(selectKid.equals("2")){
if(radioKid.equals("1")){
strSql="select * from Book where Bnumber='"+infoKid +"'";
strSql1 = "SELECT count(*) as recordcount FROM Book where Bnumber='"+infoKid +"'";
}
else if(radioKid.equals("2")){
strSql="select * from Book where Bnumber like'%"+infoKid +"%'";
strSql1 = "SELECT count(*) as recordcount FROM Book where Bnumber like'%"+infoKid +"%'";
}
}
else if(selectKid.equals("3")){
if(radioKid.equals("1")){
strSql="select * from Book where Bpincipal='"+infoKid +"'";
strSql1 = "SELECT count(*) as recordcount FROM Book where Bpincipal='"+infoKid +"'";
}
else if(radioKid.equals("2")){
strSql="select * from Book where Bpincipal like'%"+infoKid +"%'";
strSql1 = "SELECT count(*) as recordcount FROM Book where Bpincipal like'%"+infoKid +"%'";
}
}
else if(selectKid.equals("4")){
if(radioKid.equals("1")){
strSql="select * from Book where Bconcern='"+infoKid +"'";
strSql1 = "SELECT count(*) as recordcount FROM Book where Bconcern='"+infoKid +"'";
}
else if(radioKid.equals("2")){
strSql="select * from Book where Bconcern like'%"+infoKid +"%'";
strSql1 = "SELECT count(*) as recordcount FROM Book where Bconcern like'%"+infoKid +"%'";
}
}
else if(selectKid.equals("5")){
if(radioKid.equals("1")){
strSql="select * from Book where Bpdate='"+infoKid +"'";
strSql1 = "SELECT count(*) as recordcount FROM Book where Bpdate='"+infoKid +"'";
}
else if(radioKid.equals("2")){
strSql="select * from Book where Bpdate like'%"+infoKid +"%'";
strSql1 = "SELECT count(*) as recordcount FROM Book where Bpdate like'%"+infoKid +"%'";
}
}
}
else{
strSql="select * from Book";
}
try{
LoginData loginData = new LoginData();
conn = loginData.getConn();
stmt=conn.createStatement(
ResultSet.TYPE_SCROLL_INSENSITIVE,
ResultSet.CONCUR_READ_ONLY);
//算出总行数
rs = stmt.executeQuery(strSql1);
if (rs.next()) totalrecord = rs.getInt("recordcount");
rs = stmt.executeQuery(strSql);
if(totalrecord%PageSize==0)totalPage=totalrecord/PageSize;
else totalPage=(int)Math.floor(totalrecord/PageSize)+1;
if(totalPage==0)totalPage=1;
if(request.getParameter("Page")==null||request.getParameter("Page").equals(""))
Page=1;
else{
try{
Page=Integer.parseInt(request.getParameter("Page"));
}catch(java.lang.NumberFormatException e){
Page=1;
}
}
if(Page<1)Page=1;
if(Page>totalPage)Page=totalPage;
rs.absolute((Page-1)*PageSize+1);
out.print("<table border='1' width='700' cellpadding='0' cellspacing='0' bordercolor='#3366CC'>");
out.print("<tr bgcolor='#6699CC'><td><font color=''><b>"+"图书编号"+"</b></font></td>");
out.print("<td><font color=''><b>"+"图书名"+"</b></font></td>");
out.print("<td><font color=''><b>"+"主编"+"</b></font></td>");
out.print("<td><font color=''><b>"+"出版社"+"</b></font></td>");
out.print("<td><font color=''><b>"+"出版日期"+"</b></font></td>");
out.print("<td><font color=''><b>"+"到管日期"+"</b></font></td>");
out.print("<td><font color=''><b>"+"状态"+"</b></font></td>");
out.print("<td><font color=''><b>"+"副本数"+"</b></font></td>");
out.print("<td><font color=''><b>"+"类别"+"</b></font></td></tr>");
for(int iPage=1;iPage<=PageSize;iPage++) {
out.print("<TD><A HREF='ShowSearchBook.jsp?id="+rs.getString("Bnumber")+"'>"+rs.getString("Bnumber")+"</A></TD>");
out.print("<TD><A HREF='ShowSearchBook.jsp?id="+rs.getString("Bname")+"'>"+rs.getString("Bname")+"</A></TD>");
out.print("<td>"+rs.getString("Bpincipal")+"</td>");
out.print("<td>"+rs.getString("Bconcern")+"</td>");
out.print("<td>"+rs.getString("Bpdate")+"</td>");
out.print("<td>"+rs.getDate("Btodate")+"</td>");
out.print("<td>"+rs.getInt("Bstate")+"</td>");
out.print("<td>"+rs.getInt("Bcopynumber")+"</td>");
out.print("<td>"+rs.getString("Bsort")+"</td></tr>");
if(!rs.next()) break;
}
out.print("</table>");
}
catch(SQLException e){
System.out.println(e.getMessage());
}
finally{
stmt.close();
conn.close();
}
%>
</strong></span> <form action="Search.jsp" method="get">
<p><span class="STYLE2"><strong>
<%
if(Page!=1){
out.print(" <a href=Search.jsp?Page=1>第一页</a>");
out.print(" <a href=Search.jsp?Page="+(Page-1)+"></a> ");
}
if(Page!=totalPage){
out.print(" <a href=Search.jsp?Page="+(Page+1)+"></a>");
out.print(" <a hreg=Search.jsp?Page="+totalPage+"></a>");
}
%>
<br>
</strong></span><strong>输入页书</strong><span class="STYLE2"><strong>:
<input type="text" name="Page" size="5">
</strong></span><strong>页数</strong><span class="STYLE2"><strong>:<font color="red"><%=Page%>/<%=totalPage%></font>
</strong></span></p>
</form></td>
</tr>
</table></td>
</tr>
</table>
</body>
</html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -