int p = 1;//起始页
if(request.getParameter("page") != null)//判断是否是第一次显示的第一页
p = Integer.parseInt(request.getParameter("page"));
int lastp = 1;//上一页
int nextp = 1;//下一页
if(count/2>0){//count是数据库中有多少条记录,2是代表每页显示两条记录,这是在判断是否有下一页
if(count%2!=0){//判断是能在最后一页显示完整的最后两条记录
if(p<=count/2){//不能刚好显示完就要多一页
nextp = p+1;
}
}else{//能刚好显示就不能多一页
if(p<count/2){
nextp = p+1;
}
}
}
if(p>1){//判断是否有上一页
lastp = p-1;
}
if(count/2>=1)//判断是否大于一页
{
if(count%2!=0){//不能刚好在最后一页显示所有记录情况下
for(int i=1;i<=count/2+1;i++){
%>
<a href="url?page=<%=i %>&&num=<%=num %>" style="text-decoration: none;">第<%=i %>页</a>
<%}
}else{//能刚好在最后一页显示所有记录情况下
for(int i=1;i<=count/2;i++){
%>
<a href="url?page=<%=i %>" style="text-decoration: none;">第<%=i %>页</a>
<%}
}
}
%>