1、增加pagehelper

 <!-- mybatis pager -->
<dependency>
<groupId>com.github.pagehelper</groupId>
<artifactId>pagehelper</artifactId>
<version>4.1.0</version>
</dependency>

  

2、增加配置

<!--Spring和MyBatis整合-->
<bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
<property name="dataSource" ref="dataSource" />
<!--自动扫描mapping.xml文件-->
<property name="mapperLocations" value="classpath:mappers/*.xml"></property> <!-- 分页插件 -->
<property name="plugins">
<array>
<bean class="com.github.pagehelper.PageHelper">
<property name="properties">
<value>
dialect=oracle
</value>
</property>
</bean>
</array>
</property> </bean>

  

3、Service中实现

  public PageInfo<Log> queryList(int pageNum, int pageSize){
PageHelper.startPage(pageNum,pageSize);
List<Log> list = xxMapperDao.queryList();
PageInfo<Log> pageInfo = new PageInfo<>(list);
return pageInfo;
}

  

4、Controller中调用

 @RequestMapping(value = "queryLogs.htm")
public void queryLogs( HttpServletResponse response,
@RequestParam(value = "pageNum",defaultValue = "1") int pageNum,
@RequestParam(value = "pageSize",defaultValue = "10")int pageSize){
PageInfo<Log> list = iLogService.queryList(pageNum, pageSize);
... }

  

Spring 中PageHelper分页插件使用的更多相关文章

  1. 关于Spring+mybatis+PageHelper分页插件PageHelper的使用策略

    把插件jar包导入项目(具体上篇有介绍http://blog.csdn.net/qq_33624284/article/details/72821811) spring-mybatis.xml文件中配 ...

  2. 【spring boot】14.spring boot集成mybatis,注解方式OR映射文件方式AND pagehelper分页插件【Mybatis】pagehelper分页插件分页查询无效解决方法

    spring boot集成mybatis,集成使用mybatis拖沓了好久,今天终于可以补起来了. 本篇源码中,同时使用了Spring data JPA 和 Mybatis两种方式. 在使用的过程中一 ...

  3. Spring Boot整合tk.mybatis及pageHelper分页插件及mybatis逆向工程

    Spring Boot整合druid数据源 1)引入依赖 <dependency> <groupId>com.alibaba</groupId> <artif ...

  4. 如何在实际项目中使用PageHelper分页插件

    PageHelper是一个分页插件,能够简单快速的帮助开发人员完成常见的分页功能,你只需要简单的使用两行代码就可以完成一个分页效果- 最近做一个科创项目,使用Maven+SSM的环境,有分页的功能,于 ...

  5. spring boot 整合pagehelper分页插件

    Spring Boot 整合pagehelper分页插件 测试环境: spring boot  版本 2.0.0.M7 mybatis starter 版本  1.3.1 jdk 1.8 ------ ...

  6. Springboot 系列(十二)使用 Mybatis 集成 pagehelper 分页插件和 mapper 插件

    前言 在 Springboot 系列文章第十一篇里(使用 Mybatis(自动生成插件) 访问数据库),实验了 Springboot 结合 Mybatis 以及 Mybatis-generator 生 ...

  7. PageHelper分页插件的使用

    大家好!今天写ssm项目实现分页的时候用到pageHelper分页插件,在使用过程中出现了一些错误,因此写篇随笔记录下整个过程 1.背景:在项目的开发的过程中,为了实现所有的功能. 2.目标:实现分页 ...

  8. mybatis pagehelper分页插件使用

    使用过mybatis的人都知道,mybatis本身就很小且简单,sql写在xml里,统一管理和优化.缺点当然也有,比如我们使用过程中,要使用到分页,如果用最原始的方式的话,1.查询分页数据,2.获取分 ...

  9. SpringBoot入门篇--整合mybatis+generator自动生成代码+druid连接池+PageHelper分页插件

    原文链接 我们这一篇博客讲的是如何整合Springboot和Mybatis框架,然后使用generator自动生成mapper,pojo等文件.然后再使用阿里巴巴提供的开源连接池druid,这个连接池 ...

随机推荐

  1. mysql 数据库关于my.int 的相关问题

    最好在建库的时候直接建好 create database db1 charset utf8; my.int  在mysql的目录里 名曰配置文件    里面主要是内容就是 1 一般用到的就是编码不统一 ...

  2. mod_fcgid: HTTP request length 136136 (so far) exceeds MaxRequestLen (131072)

    原来是fastcgi模式下的设置问题,需要在配置文件.htaccess或者直接在apache的配置文件http.conf 中指明,如下: 查看官方说明有这么一句:Default: FcgidMaxRe ...

  3. ajax参考增删改查

    AJAX做增删改查详细!   <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "htt ...

  4. python 正则匹配时间格式转换方法

    import re from datetime import datetime a = '2018年8月9日 10:10' s = re.findall('\d+',a) print(s) d = ' ...

  5. Python 面向对象和面向过程对比

    # 大象装冰箱 # 脚本, 此时代码是最简单的. 不需要构思整个程序的概况 print("开门") print("装大象") print("关门&qu ...

  6. busybox 安装问题解决

    直接编译错误 1.loginutils/passwd.c:93:16: error: storage size of ‘rlimit_fsize’ isn’t known 解决方法:在busybox根 ...

  7. phantomjs 抓取、截图中文网站乱码的问题的解决

    用phantomjs抓取html乱码的解决方案: phantomjs --output-encoding=gbk test.js http://webscan.360.cn/index/checkwe ...

  8. post-image.sh hacking

    #********************************************************************************* #* post-image.sh ...

  9. 关于Linux前后台进程切换

    前言: 当使用SSH远程登录服务器时,对于运行时间较长的程序(如Caffe的训练可能需要十几个小时), SSH可能会在很长时间后断掉,导致程序没运行完就中断了. 为了解决这个问题,需要将在服务器运行的 ...

  10. mysql设置外键约束开启-关闭

    在MySQL中删除一张表或一条数据的时候,出现 [Err] 1451 -Cannot delete or update a parent row: a foreign key constraint f ...