📄 search.jsp
字号:
<%@ page contentType="text/html; charset=gb2312"%>
<%@include file="common.jsp"%>
<%@ include file="incoming/check.jsp"%>
<%@page import="java.util.Collection,java.util.Iterator"%>
<jsp:useBean id="cart" scope="session" class="beans.CartBean" />
<html>
<head>
<title>欢迎光临E-BOOK网上书店</title>
<link href="incoming/style.css" rel="stylesheet" type="text/css">
</head>
<body>
<%@ include file="incoming/header.jsp"%>
<jsp:include page="additem.jsp" flush="false" />
<%
String strKeyword = new String(request.getParameter("keyword").trim()
.getBytes("ISO-8859-1"));
if(null==strKeyword || strKeyword.equals(""))
{
response.sendRedirect("search2.jsp");
return;
}
Collection<BookBean> cl=bookdb.searchBook(strKeyword);
if(cl.size()<=0)
{
out.println("对不起,没有找到符合条件的图书。");
out.println("<a href=\"index.jsp\">返回</a>");
return;
}
%>
<table>
<tr>
<th>
书名
</th>
<th>
价格
</th>
<th>
查看
</th>
<th>
购买
</th>
</tr>
<%
Iterator<BookBean> it=cl.iterator();
while(it.hasNext())
{
BookBean book=(BookBean)it.next();
String title=book.getTitle();
int bookId=book.getId();
float price=book.getPrice();
%>
<tr>
<td>
<a href="bookinfo.jsp?id=<%=bookId%>">《<%=title%>》</a>
</td>
<td><%=price%></td>
<td>
<a href="bookinfo.jsp?id=<%=bookId%>">详细信息</a>
</td>
<td>
<a href="search.jsp?keyword=<%=strKeyword%>&add=<%=bookId%>">
加入购物车 </a>
</td>
</tr>
<%
}
%>
</table>
<p>
购物车中现有<%=cart.getNumOfItems()%>种图书
<a href="showcart.jsp">查看购物车</a>
<a href="index.jsp">回到主页</a><br>
<%@ include file="incoming/footer.jsp"%>
</body>
</html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -