jsp分页查询,点击下一页,上一页和下一页的查询内容都显示出来了,怎么回事
1个回答
展开全部
你要分页的同时,要控制SQL查询语句。
如以下SQL语句:
String sql2="select top "+pageLine+" * from admins where admin_n like '"+"%"+qadmin_n+"%"+"' and admin_name like '"+"%"+qadmin_name+"%"+"' and admin_n<>'"+usersi+"' and rec_id not in (select top "+((intPage-1)*pageLine)+" rec_id from admins where admin_n like '"+"%"+qadmin_n+"%"+"' and admin_name like '"+"%"+qadmin_name+"%"+"' and admin_n<>'"+usersi+"' order by rec_id desc ) order by rec_id desc ";
然后对应原JSP分页代码是:
out.print("<center> ");
if(intPageCount*pageLine<totalRec)
intPageCount++;
if(intPage>intPageCount)
intPage=intPageCount;
if(intPage<1)
intPage=1;
if(intPage<2)
out.print("首页 上一页 ");
else{
out.print("<a href='aa123.jsp?page=1' ><font color='#3300FF' size='2'>首页</font></a> ");
out.print("<a href='aa123.jsp?page="+(intPage-1)+"' ><font color='#3300FF' size='2'>上一页</font></a> ");
}
if(intPage-intPageCount>=0)
out.print("下一页 尾页");
else{
out.print("<a href='aa123.jsp?page="+(intPage+1)+"'><font color='#3300FF' size='2'>下一页</font></a> <a href='aa123.jsp?page="+intPageCount+"'><font color='#3300FF' size='2'>尾页</font></a> ");
}
out.print(" 页次:<font color=red>"+intPage+"</font>/<font color=red>"+intPageCount+"</font>页 ");
out.print("共<font color=red>"+totalRec+"</font>条记录 <font color=red>"+pageLine+"</font>条/页");
out.print("</center>");
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询