spring及springBoot分页

1:pom.xml注入依赖

<!-- mybatis的分页插件 -->
<dependency>
    <groupId>com.github.pagehelper</groupId>
    <artifactId>pagehelper</artifactId>
</dependency>

2:myBatis.xml

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE configuration
PUBLIC "-//mybatis.org//DTD Config 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-config.dtd">

<configuration>
    <!-- 【mybatis的核心配置文件】 -->

    <!-- 批量设置别名(可以不配) 作用:就是在mapper.xml文件中直接写类名,也可以不用写全路径名。 -->
    <typeAliases>
        <package name="cn.e3mall.manager.po" />
    </typeAliases>

    <!-- 配置mybatis的分页插件PageHelper -->
    <plugins>
        <!-- com.github.pagehelper为PageHelper类所在包名 -->
        <plugin interceptor="com.github.pagehelper.PageHelper">
            <!-- 设置数据库类型Oracle,Mysql,MariaDB,SQLite,Hsqldb,PostgreSQL六种数据库 -->
            <property name="dialect" value="mysql"/>
        </plugin>
    </plugins>

</configuration>

3、业务层实现

核心代码:

PageHelper.startPage(page, rows);

博客链接:https://www.cnblogs.com/onetwo/p/7371778.html

猜你喜欢

转载自blog.csdn.net/qq_35023116/article/details/80541046