• SSM+layui分页(了解98%)


    第一步:配置pom.xml

    <dependency>
          <groupId>com.github.pagehelper</groupId>
          <artifactId>pagehelper</artifactId>
          <version>5.1.10</version>
        </dependency>

    第二步:配置Spring_servlet.xml

    <bean id="sqlSessionFactoryBean" class="org.mybatis.spring.SqlSessionFactoryBean">标签中添加:

    <property name="plugins">
    <array>
    <bean class="com.github.pagehelper.PageInterceptor">
    <property name="properties">
    <value></value>
    </property>
    </bean>
    </array>
    </property>

     第三步:配置Service接口

     JsonData allShop(int limit,int page); 

     第四步:配置Service实体类,也就是ServiceImpl

    只需要一个全查询操作就可以,无需多添加

    @Override
        public JsonData allShop(int limit,int page) {
            PageHelper.startPage(page,limit);
            List<Shopinfo>  shopinfos=shopinfoMapper.allShop(limit, page);
            PageInfo<Shopinfo> pageInfo=new PageInfo<>(shopinfos);
            return JsonData.buildSuccess(pageInfo,"success");
        }

    第五步:配置Mapper接口

     List<Shopinfo> allShop(int limit,int page);

    第六步:配置Controller

    @RequestMapping("/allShop")
        @ResponseBody
        public String allShop(int limit,int page){
            JsonData allShop=shopinfoService.allShop(limit,page);
            return JSON.toJSONString(allShop);
        }

    第七步:在Layui框架中自己设定的js文件中的全查询操作“]]”之后添加

    ,parseData:function(rs){//数据格式解析
                console.log("rs===="+rs.toString()+"---"+rs.data.total+"---"+rs.data.list+"---"+rs.msg)
                return { // 里面的每一个值必须与传递的json 数据对应
                    "code":rs.code,    //返回状态码200
                    "msg":rs.msg,    // 消息
                    "count":rs.data.total,    //总条目
                    "data":rs.data.list    //具体内容
                }
            }

    记得在添加全查询路径的下一项添加

     ,page:true  //开启分页

    --------------------------------------------------------------------------------------------------------------------------感谢到访!期待您的下次光临!

  • 相关阅读:
    博客中引用的概念
    重构博客写作
    做中学之教与学工具箱
    做中学之效率工具箱
    两个月选一本理想教材
    《敏捷革命》读书笔记
    《Java2 实用教程(第五版)》学习指导
    得到.每天听本书
    「2017年教育部-永信至诚产学合作协同育人网络空间安全专业课程教学研讨会」参会总结
    Ditto在教学上的应用
  • 原文地址:https://www.cnblogs.com/varchar-pig/p/14244088.html
Copyright © 2020-2023  润新知