Springboot 整合 pagehelper 分页

pagehelper 版本

https://mvnrepository.com/artifact/com.github.pagehelper/pagehelper-spring-boot-starter

在pom.xml中添加依赖

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

不需要过多的配置,springboot中集成的基本都可以使用

前台easyui 传递分页参数

public Map<String,Object> queryShenPi(Integer page,Integer rows,ShenPiVo shenPiVo){
		PageHelper.startPage(page,rows);
		List<Psb> list = psbService.queryShenPi(shenPiVo);
		System.out.println(shenPiVo);
		System.out.println(list);
		PageInfo<Psb> info = new PageInfo<>(list);
		Map<String,Object> map = new HashMap<>();
		//{"total":总记录数量,"rows": list集合}格式传递数据
		map.put("total",info.getTotal());
		map.put("rows",info.getList());
		return map;
	}

html页面:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<script type="text/javascript" src="/js/jquery.js"></script>
<link rel="stylesheet" href="/js/easyui.css">
<link rel="stylesheet" href="/js/icon.css">
<script  src="/js/jquery.easyui.min.js" ></script>
<script  src="/js/easyui-lang-zh_CN.js"></script>
<body>
<div id="cc" class="easyui-layout" fit="true">
    <div data-options="region:'center',title:'center title'" style="padding:5px;background:#eee;">
        <table id="list" class="easyui-datagrid"></table>
    </div>
</div>
</body>
<script>
    $(function(){
        intiTabs();
    });

    //转换日期格式
    function changeDateFormat(value) {
        var date = new Date(value);
        var y = date.getFullYear();
        var m = date.getMonth() + 1;
        var d = date.getDate();
        return y + '-' +m + '-' + d;
    }


    function intiTabs(){

        $('#list').datagrid({
            url:'/goods/queryList',
            onLoadSuccess:function(data){
                $(".updateBtn").linkbutton({text:'修改',plain:true,iconCls:'icon-edit'});
                $(".infoBtn").linkbutton({text:'详情',plain:true,iconCls:'icon-search'});
                $(".deleteBtn").linkbutton({text:'删除',plain:true,iconCls:'icon-no'});
            },
            columns:[[
                {field:'goId',title:'商品ID',width:100,align:'center'},
                {field:'goName',title:'商品名称',width:100,align:'center'},
                {field:'goPrice',title:'商品价格',width:100,align:'center'},
                {field:'goCount',title:'商品库存',width:100,align:'center'},
                {field:'goDate',title:'上架时间',width:100,align:'center',
                    formatter: function(value,row,index){
                        return changeDateFormat(value);
                    }
                },
                {field:'dataBase',title:'操作',width:170,align:'center',
                    formatter: function(value,row,index){
                        var str="";
                        str+= "<a class='updateBtn' href='javascript:updateDialog()' class='easyui-linkbutton'>修改</a>";
                        str+= "<a class='infoBtn' href='javascript:queryFun()' class='easyui-linkbutton'>详情</a>";
                        str+= "<a class='deleteBtn' href='javascript:deleteFun()' class='easyui-linkbutton'>删除</a>";
                        return str;
                    }

                }

            ]],
            /* pagination 为true时 在 dataGrid底部显示分页工具 */
            pagination:true,
            /* 设置分页属性时初始化页面大小 */
            pageSize:5,
            /* 设置分页属性时,初始化页面大小的列表 */
            pageList:[5,10,25,50,100],
            fitColumns:true,
            singleSelect:true,

        });
    }
</script>
</html>

效果如下:

在这里插入图片描述

在这里插入图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值