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

分页查询功能_分析

  分页?:

    

 

   分页的好处:

      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 @ 2023-02-14 20:52  zj勇敢飞,xx永相随  阅读(36)  评论(0编辑  收藏  举报