仿google分页

 

 
 
 
图片显示的 10 就是 后面 int num=6; 定义所说的页码数
 
       Private int nowpage ; // 当前页
    Private int countrecord ; // 总记录数
    Private int countpage ; // 总页数
    Private int pageindex ; // 当前页记录开始的位置 (nowpage-1)*PAGESIZE
    Publics static final int PAGESIZE = 5; // 每页显示的记录数
    Private int sumindex = 6; // 索引的 sum 值代表的是 google 页面中最大显示页数
    Private int startindex ; // 开始的索引值
    Private int endindex ; // 结束的索引值
 
 
 
// 计算索引位置
          StudentServiceImpl ssi = new StudentServiceImpl();
       int lastpage = ssi.getCountPage(); // 获得总页数
       int startindex = 1;             // 开始索引
       int endindex = (3 + nowpage - 1)>lastpage?lastpage:(3 + nowpage - 1); // 结束索引
       int num = 6;                // 显示的页码数
       if (endindex>=num){              // 判断 最后索引值 是否大于 显示的页码数
           if (endindex>=lastpage){     // 判断 最后索引值 是否大于 最后总页数
              endindex=lastpage;
           }
           if (lastpage>num){        // 判断 总页数 是否小于 显示的页码数
              startindex=endindex-num+1;
           }
       }
       System. out .println( "endindex " + endindex + ",lastpage:" + lastpage+ ",startindex:" +startindex);
       this . startindex =startindex;
       this . endindex =endindex;
       this . nowpage =nowpage;
       this . lastpage =lastpage;
       this . num =num;
       this . li =ssi.getNowPageInfo(nowpage);

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值