久久r热视频,国产午夜精品一区二区三区视频,亚洲精品自拍偷拍,欧美日韩精品二区

您的位置:首頁技術文章
文章詳情頁

Spring Boot 中PageHelper 插件使用配置思路詳解

瀏覽:2日期:2023-12-13 18:02:27
使用思路

1.引入myabtis和pagehelper依賴

2.yml中配置mybatis掃描和實體類

這2行代碼pageNum:當前第幾頁pageSize:顯示多少條數據userList:數據庫查詢的數據數據列表

PageHelper.startPage(pageNum, pageSize);PageInfo pageInfo = new PageInfo(userList);最后返回一個pageInfo 對象即可,pageInfo 這個對象中只有數據一些信息,但是,沒有成功失敗的狀態或者提示語。真實企業中會封裝一個返回對象,把pageInfo 放到對象中

1.pom依賴

方法一:使用原生的PageHelper

1.在pom.xml中引入依賴,刷新自動加載jar

<dependency><groupId>com.github.pagehelper</groupId><artifactId>pagehelper</artifactId><version>5.2.1</version> </dependency>

方法二 本人使用 PageHelper的starter

1.導入pom.xml依賴

<dependency><groupId>com.github.pagehelper</groupId><artifactId>pagehelper-spring-boot-starter</artifactId><version>1.2.12</version> </dependency>

2.在application.properties或者application.yml格式配置pagehelper的屬性

二選一

#pagehelper分頁插件配置application.properties

pagehelper.helper-dialect=mysqlpagehelper.reasonable=truepagehelper.support-methods-arguments=truepagehelper.params=count=countSql

application.yml

hepagehelper: lperDialect: mysql reasonable: true supportMethodsArguments: true params: count=countSql

Controller層調用 測試

@RequestMapping('findallCar')public String findallCar(Model model, HttpSession session) { PageHelper.startPage(1,5); List<CarTable> carTables = service.findallCar(); PageInfo<CarTable> page = new PageInfo<CarTable>(carTables); System.out.println(page); model.addAttribute('carall', carTables); session.setAttribute('caralls', carTables); return 'carinsert';}

PageHelper.startPage(1,5); List<CarTable> carTables = service.findallCar(); PageInfo<CarTable> page = new PageInfo<CarTable>(carTables); System.out.println(page);

到此這篇關于Spring Boot 中PageHelper 插件使用配置思路詳解的文章就介紹到這了,更多相關Spring Boot PageHelper 插件內容請搜索好吧啦網以前的文章或繼續瀏覽下面的相關文章希望大家以后多多支持好吧啦網!

標簽: Spring
相關文章:
主站蜘蛛池模板: 巴塘县| 壤塘县| 晴隆县| 兴文县| 辽阳县| 房山区| 安平县| 股票| 沙田区| 武义县| 大安市| 长武县| 黄冈市| 黑山县| 怀柔区| 连江县| 米泉市| 都兰县| 高青县| 大名县| 宜城市| 青海省| 宁波市| 临漳县| 房产| 麻栗坡县| 沁源县| 抚州市| 阳西县| 峨眉山市| 延津县| 塘沽区| 凌海市| 星座| 梁平县| 阳朔县| 新干县| 绥棱县| 肃南| 博罗县| 宁波市|