pagehelper分頁原理

2021-10-21 00:23:43 字數 484 閱讀 7200

public serverresponsegetproductlist(int pagenum,int pagesize){

//startpage--start

//填充自己的sql查詢邏輯

pagehelper.startpage(pagenum,pagesize);

總結:

1、pagehelper首先將前端傳遞的引數儲存到page這個物件中

2、接著將page的副本存放入threadloacl中,threadlocal很多地方叫做執行緒本地變數,為變數在每個執行緒中都建立了乙個副本,那麼每個執行緒可以訪問自己內部的副本變數。這樣可以保證分頁的時候,引數互不影響

3、pagehelper實現了mybatis提供的***interceptor介面,呼叫其中的intercept方法,取得threadlocal的值

pagehelper在我們執行sql語句之前動態的將sql語句拼接了分頁的語句,從而實現了從資料庫中分頁獲取的過程。

PageHelper分頁實戰

1 首先pom檔案引入 com.github.pagehelper pagehelper 4.1.6 2 mybatisconfig.xml 處理 新增 listgetorderconfiglist param businesstype integer businesstype,param capi...

PageHelper分頁外掛程式

com.github.pagehelper pagehelper 5.1.2 1.在mybatis中配置 此時並沒有spring來管理mybatis 2.使用spring容器管理 此時mybatis已交由spring容器管理 1.helperdialect 分頁外掛程式會自動檢測當前的資料庫鏈結,自...

外掛程式分頁 pageHelper

步驟 1.導包 3.serivce中,給到具體的分頁的頁碼page,每頁條數 size 4.controller中把得到的資料儲存到pageinfo。5.到達頁面在pom檔案中導包 com.github.pagehelper pagehelper 5.1.2 mysql true 在service層...