当前位置: 首页 > 后端技术 > Java

页面

时间:2023-04-01 22:35:09 Java

使用limit页面内核sql1.select*fromuserlimitstartIndex,pageSize;2.select*fromuserlimit3;#[0,3)接口//页面ListgetUserByLimit(Mapmap);Mapper.xmlselect*frommybatis.userlimit#{startIndex},#{pageSize}测试@TestpublicvoidgetUserByLimit(){SqlSessionsqlSession=MybatisUtils.getSqlSession();UserMapper映射器=sqlSession.getMapper(UserMapper.class);HashMapmap=newHashMap<>();map.put("startIndex",2);map.put("pageSize",2);列表<用户>userList=mapper.getUserByLimit(map);for(Useruser:userList){System.out.println(user);}sqlSession.close();}使用RowBounds页面接口ListgetUserByRowBounds();Mapper.xmlselect*frommybatis.user测试@TestpublicvoidgetUserByRowBounds(){SqlSessionsqlSession=MybatisUtils.getSqlSession();//RowBounds实现RowBoundsrowBounds=newRowBounds(1,2);//通过Java代码层级分页ListuserList=sqlSession.selectList("com.sunfl.dao.UserMapper.getUserByRowBounds",null,rowBounds);for(Useruser:userList){System.out.println(user);}sqlSession.close();}分页插件pageHelper