久久r热视频,国产午夜精品一区二区三区视频,亚洲精品自拍偷拍,欧美日韩精品二区

您的位置:首頁技術文章
文章詳情頁

SpringBoot如何集成PageHelper分頁功能

瀏覽:3日期:2023-05-27 18:00:22

添加MyBatis的代碼并修改以下部分:

1.添加MyBatisConfig

package myshop.config;import java.util.Properties;import org.springframework.context.annotation.Bean;import org.springframework.context.annotation.Configuration;import com.github.pagehelper.PageHelper;@Configurationpublic class MyBatisConfig { @Bean public PageHelper pageHelper() { System.out.println('Use PageHelper'); PageHelper pageHelper = new PageHelper(); Properties p = new Properties(); p.setProperty('offsetAsPageNum', 'true'); p.setProperty('rowBoundsWithCount', 'true'); p.setProperty('reasonable', 'true'); pageHelper.setProperties(p); return pageHelper; }}

2.修改MyBatisController

package myshop.controller;import java.util.List;import org.springframework.beans.factory.annotation.Autowired;import org.springframework.web.bind.annotation.RequestMapping;import org.springframework.web.bind.annotation.RestController;import com.github.pagehelper.PageHelper;import myshop.bean.UserInfo;import myshop.service.MyBatisService;@RestControllerpublic class MyBatisController { @Autowired private MyBatisService myBatisService; @RequestMapping('likeName') public List<UserInfo> likeName(String username) { PageHelper.startPage(1,2); return myBatisService.likeName(username); }}

3.訪問地址

http://localhost:8080/likeName?username=天恒

以上就是本文的全部內容,希望對大家的學習有所幫助,也希望大家多多支持好吧啦網。

標簽: Spring
相關文章:
主站蜘蛛池模板: 双峰县| 金山区| 渭源县| 宽甸| 瓦房店市| 福建省| 揭东县| 湖北省| 大同市| 清徐县| 宜州市| 巢湖市| 赤城县| 剑川县| 青田县| 三原县| 福州市| 亚东县| 枞阳县| 永州市| 嘉峪关市| 沛县| 池州市| 柘城县| 合川市| 日喀则市| 油尖旺区| 额尔古纳市| 咸宁市| 英山县| 利辛县| 金寨县| 航空| 吉木萨尔县| 吉林市| 崇文区| 河源市| 武陟县| 通州区| 宜阳县| 麦盖提县|