一、导入分页插件依赖

 <!--分页插件-->
        <dependency>
            <groupId>com.github.pagehelper</groupId>
            <artifactId>pagehelper-spring-boot-starter</artifactId>
            <version>1.2.9</version>
        </dependency>

二、使用
2.1 前端js

layui.use("table", function () {
        var table = layui.table;

        table.render({
            elem: '#secondBox',
            url: 'path,
            method: 'post',
            page: true,
            limit: 10,
            limits: [10, 15],
            cols: [[
            //deviceNumber,secretKey后台实体封装类
                {field: 'deviceNumber', title: 'xxx', align: 'center', sort: true},
                {field: 'secretKey', title: 'xxx', align: 'center', sort: true},
                {field: 'deviceFirm', title: 'xxx', align: 'center', sort: true},
                {field: 'firmLoginName', title: 'xxx', align: 'center', sort: true},
                {field: 'createDeviceTime', title: 'xxx', align: 'center', sort: true},
                {field: 'createSecretKeyTime', title: 'xxx', align: 'center', sort: true}
            ]]
        });
    });

2.2 controller处理

@RequestMapping(value = "/userDefaultSecretKey/{firmCode}", method = RequestMethod.POST)
@ResponseBody
    public LayuiJson userQuerySecretKey(@PathVariable("firmCode") String firmCode, int page, int limit) {
        startPage(page, limit);
        List<SecretKey> userSecretKeyList = dataLinkageService.queryUserSecretKey(firmCode);
        PageInfo<SecretKey> secretKeyPageInfo = new PageInfo<>(userSecretKeyList);
        return new LayuiJson(0, "ok", secretKeyPageInfo.getTotal(), userSecretKeyList);
    }
Logo

开放原子开发者工作坊旨在鼓励更多人参与开源活动,与志同道合的开发者们相互交流开发经验、分享开发心得、获取前沿技术趋势。工作坊有多种形式的开发者活动,如meetup、训练营等,主打技术交流,干货满满,真诚地邀请各位开发者共同参与!

更多推荐