Analysis of the failure of springboot integration when using pageHelp

The paging function of pageHelp is used in the springboot project.
When using it, it is found that some paging has been realized and some cannot be realized.

Analyze the problem: The problem that the
paging is not implemented is manifested in: the set limit value is invalid , that is, the data limit displayed on each page does not work.

1. After confirming the pageHelp package, version, and configuration in application.properties, there is no problem (excluded options with configuration problems).

2. After checking the value of pageInfo.getTotalList(), it is determined that the back-end pageHelp.startPage() method does not work.

Finally found the problem:
that is, in the springboot project, the paging code was written in the controller layer, but in the previous ssm framework, it was implemented in the service layer.

ssm:

In the serviceImpl layer:
Insert picture description here
In ssm, the paging function is directly performed in the implementation layer of the service, and the paging code is followed by the mapper code that requires paging.

springboot:

In the controller layer:
Insert picture description here
In springboot, the paging code PageHelp.startPage() is followed by a collection of methods (referring to this method may have multiple methods of querying the database, that is, multiple mapper codes).

The pageHelp plug-in only works on the first query statement ( mapper code ) under the statement , so it will only paginate the first query statement in the set of methods.

Even though the code expression looks like the return table of the method collection is paged, pageHelp does not page the entire method collection .

Solution : Change the code structure in the method collection , and place the code that needs paging before other mapper codes.

Guess you like

Origin blog.csdn.net/Hambur_/article/details/113859640