国产成人精品亚洲777人妖,欧美日韩精品一区视频,最新亚洲国产,国产乱码精品一区二区亚洲

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

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
相關文章:
主站蜘蛛池模板: 海淀区| 宜宾县| 定结县| 西吉县| 吉木萨尔县| 云阳县| 汤阴县| 女性| 绍兴市| 靖远县| 盐津县| 巴马| 张家川| 奉贤区| 阜新市| 康保县| 师宗县| 杭州市| 密山市| 宁强县| 内黄县| 河北省| 宝丰县| 昂仁县| 德安县| 罗平县| 湘阴县| 托里县| 丰县| 云霄县| 万源市| 永川市| 灵璧县| 策勒县| 仪陇县| 大埔县| 行唐县| 正阳县| 北宁市| 罗江县| 荆州市|