📄 search.jsp
字号:
<%@ page contentType="text/html; charset=GB2312" %>
<%@ include file="/gouwuche/common.jsp" %>
<%@page import="java.util.Collection,java.util.Iterator" %>
<jsp:useBean id="cart" scope="session"
class="shop.CartBean"></jsp:useBean>
<html>
<head><title>欢迎光临网上书店</title></head>
<body>
<jsp:include page="additem.jsp" flush="false"/>
<%
String strKeyword=request.getParameter("keyword");
if(null==strKeyword || strKeyword.equals(""))
{
response.sendRedirect("catalog.jsp");
return;
}
Collection cl=pDAO.searchBook(strKeyword);
if(cl.size()<=0)
{
out.println("对不起,没有找到符合条件的图书。");
out.println("<a href=\"admingouwuche.jsp\">返回</a>");
return;
}
%>
<table>
<tr>
<th>书名</th>
<th>价格</th>
<th>查看</th>
<th>购买</th>
</tr>
<%
Iterator it=cl.iterator();
while(it.hasNext())
{
productBean pBean=(productBean)it.next();
String name=pBean.getProductName();
int productId=pBean.getProductID();
float price=pBean.getPrice();
%>
<tr>
<td><a href="prouctinfo.jsp?id=<%=productId%>"><%=name%></a></td>
<td><%=price%></td>
<td><a href="prouctinfo.jsp?id=<%=productId%>">详细信息</a></td>
<td>
<a href="search.jsp?keyword=<%=strKeyword%>&add=<%=productId%>">
加入购物车
</a>
</td>
</tr>
<%
}
%>
</table><p>
购物车中现有<%=cart.getNumOfItems()%>种图书
<a href="showcart.jsp">查看购物车</a>
<a href="index.jsp">回到主页</a>
</body>
</html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -