Mybatis分页插件

1.在pom.xml中添加依赖

<!--分页技术-->
<dependency>
    <groupId>com.github.pagehelper</groupId>
    <artifactId>pagehelper</artifactId>
    <version>4.1.4</version>
</dependency>

2.在mybatis-Config.xml中添加分页插件配置

<!--分页插件配置-->
<plugins>
    <plugin interceptor="com.github.pagehelper.PageHelper">
        <property name="dialect" value="mysql"/>
        <property name="offsetAsPageNum" value="false"/>
        <property name="rowBoundsWithCount" value="false"/>
        <property name="pageSizeZero" value="true"/>
        <property name="reasonable" value="false"/>
        <property name="supportMethodsArguments" value="false"/>
        <property name="returnPageInfo" value="none"/>
    </plugin>
</plugins>

3.service在调用dao层的方法之前加上

PageHelper.startPage(pageNum,1);//表示这一页显示一条记录

-----------------------------------------------------------------------------------------

与上面无关提示:

在dao层如果方法中有多个参数-务必使用注解@Param ------例如:

void updateStatusById(@Param("status") int status,@Param("realCheckId") String realCheckId);

 

posted @ 2018-09-20 19:14  IT晓白  阅读(137)  评论(0编辑  收藏  举报