在SpringBoot中使用PageHelper分頁(yè)插件時(shí),如果設(shè)置pagehelper.reasonable=true時(shí)锈锤,pageNum<=0 時(shí)會(huì)查詢第一頁(yè), pageNum>pages(超過(guò)總數(shù)時(shí)),會(huì)查詢最后一頁(yè)
也就是即使傳入頁(yè)數(shù)大于總頁(yè)數(shù)省店,仍然會(huì)返回?cái)?shù)據(jù)
在配置文件中,將 pagehelper.reasonable 改為 false 即可
pagehelper.reasonable=false
官方文檔中寫(xiě)道:
reasonable:分頁(yè)合理化參數(shù)蜘拉,默認(rèn)值為false萨西。當(dāng)該參數(shù)設(shè)置為 true 時(shí),pageNum<=0 時(shí)會(huì)查詢第一頁(yè)旭旭, pageNum>pages(超過(guò)總數(shù)時(shí))谎脯,會(huì)查詢最后一頁(yè)。默認(rèn)false 時(shí)持寄,直接根據(jù)參數(shù)進(jìn)行查詢源梭。