国产成人精品亚洲777人妖,欧美日韩精品一区视频,最新亚洲国产,国产乱码精品一区二区亚洲

您的位置:首頁技術(shù)文章
文章詳情頁

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

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

1.引入myabtis和pagehelper依賴

2.yml中配置mybatis掃描和實(shí)體類

這2行代碼pageNum:當(dāng)前第幾頁pageSize:顯示多少條數(shù)據(jù)userList:數(shù)據(jù)庫查詢的數(shù)據(jù)數(shù)據(jù)列表

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

1.pom依賴

方法一:使用原生的PageHelper

1.在pom.xml中引入依賴,刷新自動(dòng)加載jar

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

方法二 本人使用 PageHelper的starter

1.導(dǎo)入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層調(diào)用 測試

@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);

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

標(biāo)簽: Spring
相關(guān)文章:
主站蜘蛛池模板: 霍林郭勒市| 新竹县| 台北县| 元谋县| 油尖旺区| 龙里县| 平山县| 泸溪县| 彭泽县| 三亚市| 花莲县| 渑池县| 霍邱县| 随州市| 遵义市| 文成县| 盐源县| 阳曲县| 桓仁| 尉氏县| 夏邑县| 南靖县| 陵水| 剑河县| 偏关县| 荥经县| 阜宁县| 大邑县| 遂宁市| 肥东县| 墨竹工卡县| 五莲县| 天门市| 尚义县| 峨眉山市| 阿鲁科尔沁旗| 江陵县| 麦盖提县| 周至县| 高台县| 岳西县|