为什么我的不分页,一次返回所有数据

为什么我的不分页,一次返回所有数据

CategoryController.java

相关代码:

@Operation(summary ="后台目录列表")
@PostMapping("admin/category/list")
@ResponseBody
public ApiRestResponse listCategoryForAdmin(@RequestParam Integer pageNum,@RequestParam Integer pageSize){
    PageInfo pageInfo = categoryService.listForAdmin(pageNum,pageSize);
    return ApiRestResponse.success(pageInfo);
}

CategoryServiceImpl.java

相关代码:
@Override
public PageInfo listForAdmin(Integer pageNum, Integer pageSize){
    PageHelper.startPage(pageNum,pageSize,"type,order_num");
    List<Category> categoryList= categoryMapper.selectList();
    PageInfo pageInfo = new PageInfo(categoryList);
    return pageInfo;
}


CategoryMapper.java

List<Category> selectList();


CategoryMapper.xml

<select id="selectList"  resultMap="BaseResultMap">
  select <include refid="Base_Column_List"/>
  from imooc_mall_category
</select>


pom.xml:

<dependency>
    <groupId>com.github.pagehelper</groupId>
    <artifactId>pagehelper-spring-boot-starter</artifactId>
    <version>1.2.13</version>
</dependency>


代码如上,运行后

相关截图:

https://img1.sycdn.imooc.com//climg/645f415309a36cf706310273.jpg


结果如下:

{

    "status": 10000,

    "msg": "SUCCESS",

    "data": {

        "total": 23,

        "list": [

            {

                "id": 3,

                "name": "新鲜水果",

                "type": 1,

                "parentId": 0,

                "orderNum": 1,

                "createTime": "2019-12-18T01:17:00.000+00:00",

                "updateTime": "2019-12-28T17:11:26.000+00:00"

            },

            {

                "id": 4,

                "name": "橘子橙子",

                "type": 2,

                "parentId": 3,

                "orderNum": 1,

                "createTime": "2019-12-18T01:17:00.000+00:00",

                "updateTime": "2019-12-28T16:25:10.000+00:00"

            },

            {

                "id": 5,

                "name": "海鲜水产",

                "type": 1,

                "parentId": 0,

                "orderNum": 2,

                "createTime": "2019-12-18T01:17:00.000+00:00",

                "updateTime": "2019-12-28T16:25:20.000+00:00"

            },

            {

                "id": 6,

                "name": "精选肉类",

                "type": 1,

                "parentId": 0,

                "orderNum": 3,

                "createTime": "2019-12-18T01:17:00.000+00:00",

                "updateTime": "2019-12-28T16:25:21.000+00:00"

            },

            {

                "id": 7,

                "name": "螃蟹",

                "type": 2,

                "parentId": 5,

                "orderNum": 1,

                "createTime": "2019-12-18T01:17:00.000+00:00",

                "updateTime": "2019-12-28T16:25:15.000+00:00"

            },

            {

                "id": 8,

                "name": "鱼类",

                "type": 2,

                "parentId": 5,

                "orderNum": 2,

                "createTime": "2019-12-18T01:17:00.000+00:00",

                "updateTime": "2019-12-28T16:25:16.000+00:00"

            },

            {

                "id": 9,

                "name": "冷饮冻食",

                "type": 1,

                "parentId": 0,

                "orderNum": 4,

                "createTime": "2019-12-20T13:45:28.000+00:00",

                "updateTime": "2019-12-28T16:25:22.000+00:00"

            },

            {

                "id": 10,

                "name": "蔬菜蛋品",

                "type": 1,

                "parentId": 0,

                "orderNum": 5,

                "createTime": "2019-12-20T13:45:28.000+00:00",

                "updateTime": "2019-12-28T16:25:23.000+00:00"

            },

            {

                "id": 11,

                "name": "草莓",

                "type": 2,

                "parentId": 3,

                "orderNum": 2,

                "createTime": "2019-12-18T01:17:00.000+00:00",

                "updateTime": "2019-12-28T15:44:42.000+00:00"

            },

            {

                "id": 12,

                "name": "奇异果",

                "type": 2,

                "parentId": 3,

                "orderNum": 3,

                "createTime": "2019-12-18T01:17:00.000+00:00",

                "updateTime": "2019-12-28T16:25:12.000+00:00"

            },

            {

                "id": 13,

                "name": "海参",

                "type": 2,

                "parentId": 5,

                "orderNum": 3,

                "createTime": "2019-12-18T01:17:00.000+00:00",

                "updateTime": "2019-12-28T16:25:17.000+00:00"

            },

            {

                "id": 14,

                "name": "车厘子",

                "type": 2,

                "parentId": 3,

                "orderNum": 4,

                "createTime": "2019-12-18T01:17:00.000+00:00",

                "updateTime": "2019-12-28T16:25:12.000+00:00"

            },

            {

                "id": 15,

                "name": "火锅食材",

                "type": 2,

                "parentId": 27,

                "orderNum": 5,

                "createTime": "2019-12-18T01:17:00.000+00:00",

                "updateTime": "2020-02-11T00:42:33.000+00:00"

            },

            {

                "id": 16,

                "name": "牛羊肉",

                "type": 2,

                "parentId": 6,

                "orderNum": 1,

                "createTime": "2019-12-18T01:17:00.000+00:00",

                "updateTime": "2019-12-28T16:25:18.000+00:00"

            },

            {

                "id": 17,

                "name": "冰淇淋",

                "type": 2,

                "parentId": 9,

                "orderNum": 1,

                "createTime": "2019-12-18T01:17:00.000+00:00",

                "updateTime": "2019-12-28T16:25:18.000+00:00"

            },

            {

                "id": 18,

                "name": "蔬菜综合",

                "type": 2,

                "parentId": 10,

                "orderNum": 1,

                "createTime": "2019-12-18T01:17:00.000+00:00",

                "updateTime": "2020-02-11T00:48:27.000+00:00"

            },

            {

                "id": 19,

                "name": "果冻橙",

                "type": 3,

                "parentId": 4,

                "orderNum": 1,

                "createTime": "2019-12-18T01:17:00.000+00:00",

                "updateTime": "2020-02-11T00:37:02.000+00:00"

            },

            {

                "id": 27,

                "name": "美味菌菇",

                "type": 1,

                "parentId": 0,

                "orderNum": 7,

                "createTime": "2019-12-20T13:45:28.000+00:00",

                "updateTime": "2020-02-10T23:20:36.000+00:00"

            },

            {

                "id": 28,

                "name": "其他水果",

                "type": 2,

                "parentId": 3,

                "orderNum": 4,

                "createTime": "2019-12-18T01:17:00.000+00:00",

                "updateTime": "2019-12-28T16:25:12.000+00:00"

            },

            {

                "id": 29,

                "name": "鸭货",

                "type": 2,

                "parentId": 8,

                "orderNum": 12,

                "createTime": "2023-04-25T19:11:48.000+00:00",

                "updateTime": "2023-05-11T12:47:40.000+00:00"

            },

            {

                "id": 30,

                "name": "鸡肉",

                "type": 2,

                "parentId": 6,

                "orderNum": 11,

                "createTime": "2023-04-25T19:14:40.000+00:00",

                "updateTime": "2023-04-25T19:14:40.000+00:00"

            },

            {

                "id": 58,

                "name": "xcvba",

                "type": 3,

                "parentId": 4,

                "orderNum": 11,

                "createTime": "2023-04-25T22:20:24.000+00:00",

                "updateTime": "2023-04-25T22:20:24.000+00:00"

            },

            {

                "id": 59,

                "name": "xcba",

                "type": 3,

                "parentId": 2,

                "orderNum": 11,

                "createTime": "2023-04-25T23:44:27.000+00:00",

                "updateTime": "2023-04-25T23:44:27.000+00:00"

            }

        ],

        "pageNum": 1,

        "pageSize": 23,

        "size": 23,

        "startRow": 0,

        "endRow": 22,

        "pages": 1,

        "prePage": 0,

        "nextPage": 0,

        "isFirstPage": true,

        "isLastPage": true,

        "hasPreviousPage": false,

        "hasNextPage": false,

        "navigatePages": 8,

        "navigatepageNums": [

            1

        ],

        "navigateFirstPage": 1,

        "navigateLastPage": 1

    }

}


问题描述:

运行后,所有数据表中所有数据都返回了,没有分页,所以内容23个目录内容全部返回了,又对照了一下视频没有发现哪里错。求助。

正在回答 回答被采纳积分+1

登陆购买课程后可参与讨论,去登陆

4回答
慕沐7075796 提问者 2023-05-28 18:29:53
<dependency>
    <groupId>com.github.pagehelper</groupId>
    <artifactId>pagehelper-spring-boot-starter</artifactId>
    <version>1.4.6</version>
</dependency>

经反复研究,和源代码对照,代码没有错。


是我的springboot版本太高,最新版本,所以对应的依赖也必须是最新的。


具体修改如上,修改后,运行分布正常。


慕沐7075796 提问者 2023-05-28 18:27:54
<
com.github.pagehelperpagehelper-spring-boot-starter1.4.6


慕沐7075796 提问者 2023-05-28 18:25:54

经反复研究,和源代码对照,代码没有错。


是我的springboot版本太高,最新版本,所以对应的依赖也必须是最新的。


具体修改如下:

com.github.pagehelperpagehelper-spring-boot-starter1.4.6


运行后,正确分页。

  • 提问者 慕沐7075796 #1
    com.github.pagehelperpagehelper-spring-boot-starter1.4.6


    2023-05-28 18:27:02
  • 提问者 慕沐7075796 #2
    <dependency>
        <groupId>com.github.pagehelper</groupId>
        <artifactId>pagehelper-spring-boot-starter</artifactId>
        <version>1.4.6</version>
    </dependency>


    2023-05-28 18:28:49
好帮手慕小蓝 2023-05-15 10:29:18

同学们好,老师这里使用同学的代码配合源码并没有出现这样的问题。建议同学下载课程源码,将代码代入到源码中排查一下。

另外建议同学在代码中使用断点,查看一下每个参数的传递是否出现了问题。

祝学习愉快~

问题已解决,确定采纳
还有疑问,暂不采纳

恭喜解决一个难题,获得1积分~

来为老师/同学的回答评分吧

0 星
请稍等 ...
意见反馈 帮助中心 APP下载
官方微信

在线咨询

领取优惠

免费试听

领取大纲

扫描二维码,添加
你的专属老师