zoukankan      html  css  js  c++  java
  • 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  //开启分页

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

  • 相关阅读:
    Linux系统备份与恢复
    CentOS7修改设置静态IP和DNS
    CentOS系统基础优化16条知识汇总
    CentOS英文提示修改为中文提示的方法
    CentOS修改主机名和网络信息
    CentOS 7系统查看系统版本和机器位数
    Linux下设置SSH Server设置时间链接限制
    查看Linux下系统资源占用常用命令(top、free、uptime)
    查看CentOS系统运行了多久使用uptime命令
    设计模式(七)学习----命令模式
  • 原文地址:https://www.cnblogs.com/varchar-pig/p/14244088.html
Copyright © 2011-2022 走看看