In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly introduces SpringBoot how to integrate PageHelper to achieve paging query function, has a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, the following let the editor take you to understand it.
Import dependencies using the method
Search for pageHelper in the central warehouse sonatype and find pagehelper-spring-boot-starter
You can choose the version of your choice and select the dependency coordinates corresponding to the dependency management tool you use. For example, if the dependency management tool I use is Maven, then I will choose the dependency coordinates corresponding to Maven.
Add Maven dependencies for pagehelper-spring-boot-starter
Com.github.pagehelper pagehelper-spring-boot-starter 1.4.1
There is no need to add a dependency for MyBatis after adding this dependency, because the dependency depends on MyBatis by default:
Write a configuration file
Use the yaml format:
Pagehelper: helper-dialect: mysql reasonable: true support-methods-arguments: true params: count=countSql
Use the properties format:
# specify the dialect of the paging plug-in
Pagehelper.helper-dialect=mysql
# rationalization of pagination
Pagehelper.reasonable=true
# support method parameters
Pagehelper.support-methods-arguments=true
# configure parameter mapping
Pagehelper.params=count=countSql
Parameter description:
Please refer to the official documentation.
Prepare the data sheet
Prepare the Mapper interface
Test query all data
Running result:
The default SQL statement is to query all data
PageHelper paging query
Use the PageHelper.startPage (pageNum,pageSize) method to set the paging information, which is the current number of pages and the total number of records displayed per page
Note: this paging information must be set before the method in the mapper interface is executed.
Running result:
The PageHelper.startPage (pageNum,pageSize) method takes effect only for the next query
There are two queries for all data below, and the PageHelper.startPage (pageNum,pageSize) method is inserted before the first query, so the first query is a paging query, while the second query does not insert a PageHelper.startPage (pageNum,pageSize) method, so it is not a paging query.
Running result:
Verify that all the data in the database is indeed only 7:
Thank you for reading this article carefully. I hope the article "how to integrate SpringBoot with PageHelper to achieve paging query function" shared by the editor will be helpful to everyone. At the same time, I also hope that you will support and pay attention to the industry information channel. More related knowledge is waiting for you 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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.