SpringBoot integrated pagination plug pageHelper paging parameters lead to failure

1, Bug reproduction

  When the postman test, passing the current page pageNum, the number of per page: pageSize, after two parameters, then regardless of any incoming pageSize interface pageSize return values ​​are fixed, inconsistent with the incoming values.

2, problem analysis

There is a problem, look at the configuration

2.1 pom File Checker

<!-- pageHelper分页插件 -->
<dependency>
    <groupId>com.github.pagehelper</groupId>
    <artifactId>pagehelper-spring-boot-starter</artifactId>
    <version>1.2.12</version>
</dependency>

After reading it, and found no problems.

2.2 application.yml configuration check

# pageHelper分页配置
pagehelper:
  helper-dialect: mysql
  reasonable: false
  support-methods-arguments: true
  params: count=countSql

Looked at the configuration, online bloggers say, the problem of reasonable configuration parameters.

The problem in this parameter on reasonable configuration, reasonable can be understood as whether to open automatically optimized default is false, 
it will return to the page containing the most recent data from the data input page number of the page if the query is true when no data (data of the last data or page data of the first page).
Direct return empty if the page is set to false when the query is no data.

But then I looked at the set time, it is changed to false, so it appears that this is not the problem.

See here, since the problem is not configured, can only be a question of the code logic processing.

2.3 Check code logic

First paste the following error code:

 After After seeing here, only to find yourself using pageHelper the startpage method, the use of a user query information department, leading to failure of paging parameters.

3, problem solving

Since I can not use that method after startpage pageHelper, it would first check the page before a wave, so as not to destroy it using rules defined, and it turned out that this method is feasible.

 Test results are as follows:

Reference blog:

https://blog.csdn.net/qq_38217237/article/details/84892619

https://blog.csdn.net/qq_38217237/article/details/89061751

 

Guess you like

Origin www.cnblogs.com/cndarren/p/12558234.html