1    首先需要在mybatis的配置文件SqlMapConfig.xml文件中配置pagehelper插件

<plugins>
<plugin interceptor="com.github.pagehelper.PageHelper">
        <!--配置数据库的方言-->
<property name="dialect" value="mysql"/>
</plugin>
</plugins>

2   在spring配置文件中添加

<!--配置mybatis  -->
<bean id="sqlSessionFactoryBean" class="org.mybatis.spring.SqlSessionFactoryBean">
<property name="configLocation" value="classpath:mybatis/SqlMapConfig.xml"></property>
<property name="dataSource" ref="dataSource"></property>
</bean>

3         使用步骤

/**
*page为页码,rows为每页要显示多少条数据
*/ @Override
public DatagridBean selectAllUser(Integer page, Integer rows) throws Exception {
PageHelper.startPage(page, rows);
/*UserExample example = new UserExample();
List<User> users = userMapper.selectByExample(example);*/
List<User> users = customUserMapper.selectAllUsers();
PageInfo<User> pageInfo = new PageInfo<>(users);
DatagridBean result = new DatagridBean();
result.setTotal(pageInfo.getTotal());
result.setRows(pageInfo.getList());
return result;
}

最新文章

  1. CentOS6.4 安装Sphinx 配置MySQL数据源
  2. iOS学习资料
  3. iOS XML &#160;解析(原生的)
  4. Chrome内嵌 FlashPlayer(PPAPI)会被页面DHTML元素遮住的问题
  5. python 有关矩阵行列的存取 np.array
  6. MsoShapeType /InlineShape枚举
  7. Linux C判断日期格式是否合法
  8. VC++ 控制台不自动退出
  9. javascript中用来定义引用类型的一种&quot;默认&quot;模式
  10. JAVA----类的继承1(extends)
  11. css 弹性盒兼容性写法,直接复制粘贴
  12. Free Goodies UVA - 12260 贪心
  13. C# linq左连接与分组
  14. IDEA2017.3.3创建第一个javaweb项目及tomcat部署实战
  15. tf.variable和tf.get_Variable以及tf.name_scope和tf.variable_scope的区别
  16. Charles抓包软件简介
  17. MyBatis基础:MyBatis调用存储过程(6)
  18. Jquery中 .empty()和.append()
  19. 了解可执行的NPM包
  20. ffmpeg文件切片

热门文章

  1. Java中的包含义
  2. [UWP]了解TypeConverter
  3. Linux主机SSH免密设置解析
  4. ES6初体验
  5. Python 集体智慧编程PDF
  6. java随机生成验证码
  7. Mockplus设计大赛获奖选手专访 | High音:轻松生活,随心嗨音
  8. Docker(六):Docker网络配置进阶
  9. 扩展1 - Python 获取当前时间的用法
  10. 重启网络服务时 Bringing up interface eth0