Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to integrate pagehelper paging function with Springboot

2025-03-21 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly explains "Springboot how to integrate pagehelper paging function", interested friends may wish to have a look. The method introduced in this paper is simple, fast and practical. Next let the editor to take you to learn "Springboot how to integrate pagehelper paging function" bar!

Add dependencies

Find the version of pagehelper in maven

Add dependencies in pom

Com.github.pagehelper pagehelper-spring-boot-starter 1.2.2

2. Use

Many articles on the network will say that it needs to be configured in application.properties.

In fact, there is no need at all, and the default settings already meet most of the needs.

Just use it directly.

@ RequestMapping (value = "getApps.do") public String getApps (Apps apps) {PageHelper.startPage (apps.getPageNum (), apps.getPageSize ()); ArrayList appsList = appsService.getApps (apps); PageInfo appsPageInfo = new PageInfo (appsList); return JSON.toJSONString (appsPageInfo);}

PageHelper.startPage (the number of pages to be displayed and the number of pages to be displayed per page)

The next line is followed by the query statement, do not write anything else, otherwise there will be no effect.

PageHelper.startPage (apps.getPageNum (), apps.getPageSize ()); ArrayList appsList = appsService.getApps (apps)

This only has a paging effect, and there is no detailed information on the total number of pages and so on.

If you have a need for the number of pages, you need to add the following line

PageInfo appsPageInfo = new PageInfo (appsList)

This satisfies all the paging requirements.

At this point, I believe that everyone on the "Springboot how to achieve integration of pagehelper paging function" have a deeper understanding, might as well to the actual operation of it! Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report