jsp分页显示时点下一页还是第一页的内容
introwcount=0;//表中的记录数intpagesize=10;//每页多少条记录intpagecount=0;//一共多少页面intpagenow=1;//用...
int rowcount=0;//表中的记录数
int pagesize=10;//每页多少条记录
int pagecount=0;//一共多少页面
int pagenow=1;//用户选择的页面号(第几页)
String s_count=request.getParameter("pagenow");//接收选择的链接页面
// out.println(s_count);
if(s_count!=null)
{
pagenow=Integer.parseInt(s_count);
}
// out.println(pagenow);
//***********************************
dataconn d1=new dataconn();
Connection conn=d1.getcon();
Statement stmt=conn.createStatement();
String sql="Select count(*) from system_news";
ResultSet rs=stmt.executeQuery(sql);
if (rs.next())
{
rowcount=rs.getInt(1);//记录数
//out.println(rowcount);//打印记录数
//rs.close();
}
if(rowcount%pagesize==0)
{
pagecount=rowcount/pagesize;
// out.println(pagecount);
}
else
{
pagecount=rowcount/pagesize+1;
// out.println(pagecount);
}
//desc 降序
//asc 升序
//sql="select * from login";
int sum=pagesize*(pagenow-1);
//out.println(sum);
if(sum==0)//当前页第一页时
{
sql="select top "+pagesize+" * from system_news order by id desc";
}
else{//当前页不是第一页时
sql="select top "+pagesize+" * from system_news where id not in(select top "+sum+" id from system_news order by id desc)order by id desc";
}
// sql="select * from login";
rs=stmt.executeQuery(sql); 展开
int pagesize=10;//每页多少条记录
int pagecount=0;//一共多少页面
int pagenow=1;//用户选择的页面号(第几页)
String s_count=request.getParameter("pagenow");//接收选择的链接页面
// out.println(s_count);
if(s_count!=null)
{
pagenow=Integer.parseInt(s_count);
}
// out.println(pagenow);
//***********************************
dataconn d1=new dataconn();
Connection conn=d1.getcon();
Statement stmt=conn.createStatement();
String sql="Select count(*) from system_news";
ResultSet rs=stmt.executeQuery(sql);
if (rs.next())
{
rowcount=rs.getInt(1);//记录数
//out.println(rowcount);//打印记录数
//rs.close();
}
if(rowcount%pagesize==0)
{
pagecount=rowcount/pagesize;
// out.println(pagecount);
}
else
{
pagecount=rowcount/pagesize+1;
// out.println(pagecount);
}
//desc 降序
//asc 升序
//sql="select * from login";
int sum=pagesize*(pagenow-1);
//out.println(sum);
if(sum==0)//当前页第一页时
{
sql="select top "+pagesize+" * from system_news order by id desc";
}
else{//当前页不是第一页时
sql="select top "+pagesize+" * from system_news where id not in(select top "+sum+" id from system_news order by id desc)order by id desc";
}
// sql="select * from login";
rs=stmt.executeQuery(sql); 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询