日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

Mybatis-plugins分页助手实现查询数据分页

發布時間:2024/10/5 编程问答 35 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Mybatis-plugins分页助手实现查询数据分页 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

其他具體代碼接上文-》mybatis自定義處理器

1.導入坐標

<dependency><groupId>com.github.pagehelper</groupId><artifactId>pagehelper</artifactId><version>3.7.5</version></dependency><dependency> <!-- 解析器--><groupId>com.github.jsqlparser</groupId><artifactId>jsqlparser</artifactId><version>0.9.1</version></dependency>

2.在UserMapper(dao)接口中定以findAll方法

public List<User> findAll();

2.在UserMapper.xml中添加sql查詢

<select id="findAll" resultType="user">select * from user</select>

3.測試

public class MapperTest {@Testpublic void test1() throws IOException {InputStream stream = Resources.getResourceAsStream("SqlMapConfig.xml");SqlSession sqlSession = new SqlSessionFactoryBuilder().build(stream).openSession();UserMapper mapper = sqlSession.getMapper(UserMapper.class);// 設置分頁相關參數PageHelper.startPage(2,3);List<User> list = mapper.findAll();//獲得與分頁相關的參數PageInfo<User> pageInfo=new PageInfo<User>(list);System.out.println("當前頁:"+pageInfo.getPageNum());System.out.println("每頁顯示條數:"+pageInfo.getPageSize());System.out.println("總條數:"+pageInfo.getTotal());System.out.println("總頁數:"+pageInfo.getPages());System.out.println("上一頁:"+pageInfo.getPrePage());System.out.println("下一頁:"+pageInfo.getNextPage());System.out.println("是否是第一頁:"+pageInfo.isIsFirstPage());System.out.println("是否是最后一頁:"+pageInfo.isIsLastPage());for(User user:list){System.out.println(user);}} }

4.結果

總結

以上是生活随笔為你收集整理的Mybatis-plugins分页助手实现查询数据分页的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。