searchbook_post.jsp
来自「用Jsp实现的图书管理系统代码」· JSP 代码 · 共 47 行
JSP
47 行
<%@ page contentType="text/html; charset=gb2312" language="java" import="java.sql.*" errorPage="" %>
<jsp:useBean id="search" class="conndb.DbConnBean" scope="request" />
<%
String sql="";
String keyword=request.getParameter("keyword");
String tkeyword=search.chStr(keyword);//解决中文乱码
String keytype=request.getParameter("type");
if(keytype.equals("booktitle")){sql="select * from book where title like '%"+tkeyword+"%'";}
else if(keytype.equals("bookid")){sql="select * from book where bookID like '%"+tkeyword+"%'";}
Connection conn=search.getConn();
Statement stmt=conn.createStatement();
ResultSet rs=stmt.executeQuery(sql);
String color="#CCCCCC";
int id=0;
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>图书查询结果</title>
</head>
<body>
<%@ include file="top.jsp" %>
<table width="72%" border="0" align="center">
<tr bgcolor="00CCFF" >
<td>序号</td><td>书名</td><td>图书编号</td><td>分类</td><td>库存量</td>
</tr>
<%
while(rs.next()){
String booktitle=rs.getString(2);
String bookid=rs.getString(3);
String booktype=rs.getString(4);
int quantity=rs.getInt(5);
id++;
if(color=="#CCCCCC"){color="#999999";}
else{color="#CCCCCC";}
%>
<tr bgcolor=<%=color%>>
<td><%=id%></td><td><%=booktitle%></td><td><%=bookid%></td><td><%=booktype%></td><td><%=quantity%></td>
</tr>
<%}%>
</table>
<%@ include file="bottom.jsp" %>
</body>
</html>
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?