日期:2014-05-17 浏览次数:20697 次
<%@ page contentType="text/html" pageEncoding="GBK"%>
<%@page import="cn.yz.factory.DAOFactory,cn.yz.dao.*,cn.yz.vo.*" %>
<%@page import="java.util.*" %>
<style type="text/css">
.STYLE6 {font-size: 12px}
.STYLE10 {font-size: 14px; font-weight: bold; }
table
{
border-collapse:collapse;
width:100%;
}
table,th,td
{
border:1px solid blue;
}
</style>
<script type="text/javascript">
function changeColor(obj,color){
obj.bgColor = color ;
}
</script>
<%!
public static final String URL = "product_list.jsp" ;
%>
<%
int currentPage = 1 ; // 为当前所在的页,默认在第1页
int lineSize = 3 ; // 每次显示的记录数
long allRecorders = 0 ; // 表示全部的记录数
String keyWord = request.getParameter("kw") ; // 接收查询关键字
%>
<%
try{
currentPage = Integer.parseInt(request.getParameter("cp")) ;
} catch(Exception e) {}
try{
lineSize = Integer.parseInt(request.getParameter("ls")) ;
} catch(Exception e) {}
if(keyWord == null){
keyWord = "" ; // 如果模糊查询没有关键字,则表示查询全部
}
%>
<%
IProductDAO dao = DAOFactory.getIProductDAOInstance() ;
List<Product> all = dao.findAll(keyWord,currentPage,lineSize) ;
allRecorders = dao.getAllCount(keyWord);
%>
<div align="center">
<h1>商品列表</h1><%=allRecorders%>
<jsp:include page="split_page_plugin.jsp">
<jsp:param name="allRecorders" value="<%=allRecorders%>"/>
<jsp:param name="url" value="<%=URL%>"/>
<jsp:param name="currentPage" value="<%=currentPage%>"/>
<jsp:param name="lineSize" value="<%=lineSize%>"/>
</jsp:include>
<table>
<TR onMouseOver="changeColor(this,'white')" onMouseOut="changeColor(this,'F2F2F2')">
<td align="center" valign="middle"><span class="STYLE10">编号</span></td>
<td align="center" valign="middle"><span class="STYLE10">名称</span></td>
<td align="center" valign="middle"><span class="STYLE10">价格</span></td>
<td align="center" valign="middle"><span class="STYLE10">数量</span></td>
<td align="center" valign="middle"><span class="STYLE10">简介</span></td>
<td align="center" valign="middle"><span class="STYLE10">购买</span></td>
</TR>
<%
Iterator<Product> iter = all.iterator() ;
while(iter.hasNext()){
Product pro = iter.next() ;
%>
<TR onMouseOver="changeColor(this,'white')" onMouseOut="changeColor(this,'F2F2F2')">
<td align="center" valign="middle"><span class="STYLE6"><%=pro.getPid()%></span></td>
<td align="center" valign="middle"><span class="STYLE6"><a href="product_show.jsp?pid=<%=pro.getPid()%>"><%=pro.getName()%></a></span></td>
<td align="center" valign="m