你要分页的同时,要控制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(""); ");
if(intPageCount*pageLineintPageCount++;
if(intPage>intPageCount)
intPage=intPageCount;
if(intPage<1)
intPage=1;
if(intPage<2)
out.print("首页 上一页 ");
else{
out.print("首页 ");
out.print("上一页 ");
}
if(intPage-intPageCount>=0)
out.print("下一页 尾页");
else{
out.print("下一页 尾页 ");
}
out.print(" 页次:"+intPage+"/"+intPageCount+"页 ");
out.print("共"+totalRec+"条记录 "+pageLine+"条/页");
out.print("