分页查询功能_分析与分页查询功能_代码实现_分析具体步骤

分页查询功能_分析

  分页?:

    

 

   分页的好处:

      1.减轻服务器内存的开销

      2.提升用户体验

 

 分页对象  PageBean     

      int totalCount; // 总记录数

      int totalPage;//总页码=总记录数%每页显示条数=- 0﹖总记录数/每页显示条数∶总记录数╱每页显示条数+

      List list;//每页的数据list集合

      int currentPage;// 当前页码

    

    totalCount = select   count(*)  from user ;

    totalPage =提供每页显示杀数给服务器: rows

    list = select * from user limit ?,?
    第一个?:开始查询的索引

    第二个?: rows每员显示的条数

    currentPage =提供当前页码给服务器
    开始查询的索引=currentPage  -1 * rows

        

 

 

 

  

分页查询功能_代码实现_分析具体步骤

 

  FindUserByPageServlet            

1.接受请求参数currentPage , rows

2.调用Service查询PageBean

3.将PageBean存入request

4.转发list.jsp展示

 

UserService
PageBean<User> findUserByPage(int currentPage ,int rows){

1.创建空的PageBean对象

2.设置当前页面属性和rows属性

3.调用dao香询totaiCount总记泉数dao.findTotalCount() ;

4. start =(currentPage - 1)* rows

5.调用dao查询list集合

dao.findByPageint start,int rows)

6.计算总页码

7.返回PageBean对象

 

UserDao
//查询总记录数
int findTotalCount()
//分页查询List
List findByPage(int start,int rows)

  

 

posted @   zj勇敢飞,xx永相随  阅读(40)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 分享4款.NET开源、免费、实用的商城系统
· 全程不用写代码,我用AI程序员写了一个飞机大战
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了
· 上周热点回顾(2.24-3.2)
点击右上角即可分享
微信分享提示