SpringMVC+Mybatis+Pagehelper实现分页,SpringMVC+Mybatis+Pagehelper实现分页,

springMVC实现分页三步骤:

1.导入pom依赖或jar包,这里使用的是jar包

pagehelper-5.1.4.jar

jsqlparser-0.8.0.jar

 2.在mybatis-config.xml中添加分页插件的设置

<!--分页插件的设置-->
    <plugins>
        <plugin interceptor="com.github.pagehelper.PageInterceptor">
            <!--标明底层连接那种数据库-->
            <property name="helperDialect" value="oracle"></property>
            <!--页码合理化-->
            <property name="reasonable" value="true"></property>
        </plugin>
    </plugins>

3.service层

//设置当前页,页容量,一般前台传入
PageHelper.startPage(pageNum, pageSize);

//查询数据库数据
List<MerchantBusinessDTO> businessDTOList = merchantInsureTempBaseMapper.businessQuery(merchantBusinessDTO);

//将查询到的数据放入PageInfo
PageInfo<MerchantBusinessDTO> pageInfo = new PageInfo<>(businessDTOList);

//然后打印pageInfo,就能看到分页的相关数据......>

猜你喜欢

转载自blog.csdn.net/qq_45001053/article/details/126278612