结果图
代码
<%@page import="org.jsoft.vo.GoodsVO"%>
<%@page import="org.jsoft.dao.GoodsDAO,java.util.List"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!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=UTF-8">
<title>Insert title here</title>
</head>
<body>
<%!
int total_page;//总页数
int up_page;//上一页
int down_page;//下一页
int every_page=6;//每页六条数据
int now_page;//当前页
%>
<center>
<table border="1" cellspacing="0">
<tr>
<td>编号</td>
<td>名称</td>
<td>价格</td>
<td>数量</td>
</tr>
<%
GoodsDAO gd=new GoodsDAO();
List<GoodsVO> lgv=gd.select_Notes();
int total_size=lgv.size();
total_page=(total_size+every_page-1)/every_page;
if(total_size==0){}else{
String now_p=request.getParameter("now_page");
if(now_p!=null){
now_page=Integer.parseInt(now_p);
}else{
now_page=1;
}
if(now_page==1){
up_page=now_page;
}else{
up_page=now_page-1;
}
if(now_page==total_page){
down_page=now_page;
}else{
down_page=now_page+1;
}
List<GoodsVO> lg=gd.select_Notes((now_page-1)*every_page,every_page);
for(GoodsVO gv:lg){
%>
<tr>
<td><%= gv.getNid()%></td>
<td><%= gv.getName()%></td>
<td><%= gv.getPrice()%></td>
<td><%= gv.getNumber()%></td>
</tr>
<%} %>
</table>
<caption>
总页为<%=total_page %> 当前页为<%=now_page %> <a href="Select.jsp?now_page=<%=up_page%>">上一页</a> <a href="Select.jsp?now_page=<%=down_page%>">下一页</a>
</caption>
<%} %>
</center>
</body>
</html>