在使用SSM框架的项目中,通过pagehelper分页助手代码实现分页

 pom.xml中增加以下内容

<!--分页助手!!!-->
<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>0.9.5</version>
</dependency>

配置分页助手插件(在你的映射配置文件中:如sqlMapConfig.xml)

增加如下内容:

<plugins>
        <plugin interceptor="com.github.pagehelper.PageHelper">
            <!--不同的数据库,查询的sql结构化语言是不同的,这里mysql-->
            <property name="dialect" value="mysql"/>
        </plugin>
</plugins>

 即配置完成。

实际使用:

3d013d96b00b4e3284b98b0f80302433.png

 c141d200460d49d4bdddded3dbbebedb.png

 cbea99a542db4e72b7085f3d5a1422bf.png

只显示了三条,实现了分页查询。 

获得分页相关参数,可以参照下图:

 4d6610d7d52a4f869d14abc1683445c3.jpeg

猜你喜欢

转载自blog.csdn.net/qq_41954181/article/details/130030724