詳解springboot-mysql-pagehelper分頁(yè)插件集成
pagehelper分頁(yè)插件
springboot-mysql-pagehelper集成
pagehelperjar:
<dependency> <groupId>com.github.pagehelper</groupId> <artifactId>pagehelper-spring-boot-starter</artifactId> <version>0.1.0</version> </dependency>
application.properties配置:
#pagehelper,方言 pagehelper.helperDialect=mysql pagehelper.reasonable=true pagehelper.supportMethodsArguments=true pagehelper.pageSizeZero=true pagehelper.params=count=countSql
分頁(yè)插件使用:(緊跟查詢即可完成分頁(yè))
/** * http://127.0.0.1:8097/hello1?a=1&b=50 * @param request * @return * @throws SQLException */ @RequestMapping(value = "/hello1", method = RequestMethod.GET) @ResponseBody public PageInfo<String> index1(HttpServletRequest request,@RequestParam("a") int pageNum, @RequestParam("b") int pageSize) throws SQLException { if (StringUtils.isEmpty(pageNum)) { pageNum=0; pageSize=10; } PageHelper.startPage(pageNum, pageSize);//頁(yè)碼,每頁(yè)顯示數(shù)量 List<String> stringlist = (List<String>) iBaseService.findList("usermapper.selectuserlist",null); PageInfo<String> pageInfo = new PageInfo<String>(stringlist); return pageInfo; }
使用方式二:
@RequestMapping(value = "/hello11", method = RequestMethod.GET) @ResponseBody public Map<String, Object> index11(HttpServletRequest request,@RequestParam("a") int pageNum, @RequestParam("b") int pageSize) throws SQLException { if (StringUtils.isEmpty(pageNum)) { pageNum=0; pageSize=10; } PageHelper.startPage(pageNum, pageSize);//頁(yè)碼,每頁(yè)顯示數(shù)量 List<String> stringlist = (List<String>) iBaseService.findList("usermapper.selectuserlist",null); PageInfo<String> pageInfo = new PageInfo<String>(stringlist); Map<String, Object>datamap=new HashMap<String, Object>(); datamap.put("pagenum", pageInfo.getPageNum()); datamap.put("pagesize", pageInfo.getPageSize()); datamap.put("dataSize", pageInfo.getTotal()); datamap.put("datalist", pageInfo.getList()); return datamap; }
到此這篇關(guān)于springboot-mysql-pagehelper分頁(yè)插件集成的文章就介紹到這了,更多相關(guān)springboot-mysql-pagehelper分頁(yè)插件內(nèi)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
相關(guān)文章
SpringBoot之@Value獲取application.properties配置無(wú)效的解決
這篇文章主要介紹了SpringBoot之@Value獲取application.properties配置無(wú)效的解決方案,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教2023-03-03JAVA實(shí)現(xiàn)的CrazyArcade泡泡堂游戲
CrazyArcade泡泡堂游戲,一款用Java編寫的JavaSwing游戲程序。 使用了MVC模式,分離了模型、視圖和控制器,使得項(xiàng)目結(jié)構(gòu)清晰易于擴(kuò)展,使用配置文件來(lái)設(shè)置游戲基本配置,擴(kuò)展地圖人物道具等。同時(shí),該程序編寫期間用了單例模式、工廠模式、模板模式等設(shè)計(jì)模式。2021-04-04Spring解決循環(huán)依賴的方法(三級(jí)緩存)
今天,我們要說(shuō)的是spring是如何解決循環(huán)依賴的。對(duì)于一個(gè)問(wèn)題說(shuō)解決之前,我們首先要先明確形成問(wèn)題的本因。那么循環(huán)依賴,何為循環(huán)依賴呢?感興趣的朋友跟隨小編一起看看吧2021-11-11Java基礎(chǔ)之?dāng)?shù)組的初始化過(guò)程
Java數(shù)組分為靜態(tài)和動(dòng)態(tài)初始化,靜態(tài)初始化中,程序員設(shè)定元素初始值,系統(tǒng)決定長(zhǎng)度;動(dòng)態(tài)初始化中,程序員設(shè)定長(zhǎng)度,系統(tǒng)提供初始值,數(shù)組初始化后長(zhǎng)度固定,存儲(chǔ)在堆內(nèi)存中,數(shù)組變量在棧內(nèi)存指向堆內(nèi)存數(shù)組對(duì)象,基本類型數(shù)組存儲(chǔ)數(shù)據(jù)值,引用類型數(shù)組存儲(chǔ)對(duì)象引用2024-10-10spring boot + mybatis如何實(shí)現(xiàn)數(shù)據(jù)庫(kù)的讀寫分離
這篇文章主要給大家介紹了關(guān)于spring boot + mybatis如何實(shí)現(xiàn)數(shù)據(jù)庫(kù)的讀寫分離的相關(guān)資料,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家學(xué)習(xí)或者使用spring boot具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面來(lái)一起學(xué)習(xí)學(xué)習(xí)吧2019-09-09Java技能點(diǎn)之SimpleDateFormat進(jìn)行日期格式化問(wèn)題
這篇文章主要介紹了Java技能點(diǎn)之SimpleDateFormat進(jìn)行日期格式化問(wèn)題,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教2023-04-04解決IDEA中快捷鍵Alt+Enter不能使用的問(wèn)題
這篇文章主要介紹了解決IDEA中快捷鍵Alt+Enter不能使用的問(wèn)題,本文通過(guò)圖文并茂的形式給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2020-12-12