zoukankan      html  css  js  c++  java
  • SSM项目使用PageHelper插件实现分页

    1.在pom.xml中添加

            <!--pagehelper分页插件 -->
            <dependency>
                <groupId>com.github.pagehelper</groupId>
                <artifactId>pagehelper</artifactId>
                <version>4.1.6</version>
            </dependency>
            <dependency>
                <groupId>com.github.jsqlparser</groupId>
                <artifactId>jsqlparser</artifactId>
                <version>1.2</version>
            </dependency>        

    2.maybatis配置文件中添加(我的配置文件是在applicationCoontent.xml)

    <!-- 分页插件 -->
           <property name="plugins">
               <array>
               <!-- com.github.pagehelper为PageHelper类所在包名 -->
                   <bean class="com.github.pagehelper.PageHelper">
                       <property name="properties">
                           <value>
                               dialect=mysql
                           </value>
                       </property>
                   </bean>
               </array>
           </property> 

    添加的位置如下:

     3.在service的实现类中分页:

        PageHelper.startPage(page, limit);
            List<Deformity> list = deformityDao.selectByMap(chinaName);
            // 分页查询
            PageInfo<Deformity> pageInfo = new PageInfo<Deformity>(list);
            return new ResultData(true, "查询成功", pageInfo.getList(), pageInfo.getTotal());

    标红的代码是主要分页的代码。

    就是这么简单,你学废了吗?感觉有用的话,给笔者点个赞吧 !
  • 相关阅读:
    JSON 数字排序 多字段排序
    hdu-4747-Mex
    Android SDK更新缓慢或无法更新的解决方法
    UVA 11806
    SDL显示内存中的图像
    Cocos2d-x 2.1.5 简单动画
    codeforce343A
    android 控件的移动
    Erlang千万级用户游戏框架(Openpoker)源码文件分析清单
    八大排序c++可运行精简版,一目了然
  • 原文地址:https://www.cnblogs.com/zys2019/p/14481112.html
Copyright © 2011-2022 走看看