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

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

SpringBoot如何集成PageHelper分頁功能

瀏覽:5日期: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
相關文章:
主站蜘蛛池模板: 林芝县| 鄂温| 常德市| 玉溪市| 铅山县| 张家界市| 青浦区| 宿松县| 兖州市| 五华县| 德州市| 交城县| 西昌市| 周口市| 平陆县| 工布江达县| 务川| 莱阳市| 锡林郭勒盟| 六盘水市| 潞城市| 东莞市| 凭祥市| 廊坊市| 枞阳县| 永修县| 武穴市| 比如县| 静宁县| 涞源县| 兴和县| 盐山县| 新疆| 肥乡县| 岳普湖县| 宁河县| 区。| 东平县| 微博| 金沙县| 光泽县|