# paging **Repository Path**: wisdomwz/paging ## Basic Information - **Project Name**: paging - **Description**: mybatis分页插件pagehelper的简单使用 - **Primary Language**: Java - **License**: Apache-2.0 - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2018-05-15 - **Last Updated**: 2020-12-19 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # paging #### 项目介绍 mybatis分页插件pagehelper的简单使用 #### 软件架构 springmvc+spring+mybatis #### 使用说明 1.搭建基本的ssm架构,使用逆向工程生成dao和pojo,搭建过程见源码。在pom文件中添加mybatis和pagehelper的依赖,如下。 ``` org.mybatis mybatis ${mybatis.version} org.mybatis mybatis-spring ${mybatis.spring.version} com.github.miemiedev mybatis-paginator ${mybatis.paginator.version} com.github.pagehelper pagehelper ${pagehelper.version} ``` 2.在mybatis的配置文件`SqlMapConfig.xml`中添加pagehelper插件,如下。 ``` ``` 3.controller层代码 ```$xslt @RequestMapping("/page") public String page(@RequestParam(defaultValue = "1") int page, Model model) { //page默认值是1,pageSize默认是10,意思是从第1页开始,每页显示10条记录。这里指定每页显示3条数据,也可以通过前端的参数传递 PageHelper.startPage(page, 3); //获取所有customer List customerList = customerService.getCustomerList(); //使用PageInfo封装 PageInfo p = new PageInfo(customerList); model.addAttribute("page", p); model.addAttribute("customerList", customerList); return "page"; } ``` 4.page.jsp ```$xslt <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> <%@ page contentType="text/html;charset=UTF-8" language="java" %> Title
用户名 密码 email phone 创建时间 修改时间
${list.username} ${list.password} ${list.email} ${list.phone} ${list.createTime} ${list.updateTime}

${page.pageNum}/${page.pages}

第一页 上一页 下一页 最后页
``` #### 安装步骤 下载源码到IDE中,修改数据库连接信息,运行sql脚本。 #### 码云特技 1. 使用 Readme\_XXX.md 来支持不同的语言,例如 Readme\_en.md, Readme\_zh.md 2. 码云官方博客 [blog.gitee.com](https://blog.gitee.com) 3. 你可以 [https://gitee.com/explore](https://gitee.com/explore) 这个地址来了解码云上的优秀开源项目 4. [GVP](https://gitee.com/gvp) 全称是码云最有价值开源项目,是码云综合评定出的优秀开源项目 5. 码云官方提供的使用手册 [http://git.mydoc.io/](http://git.mydoc.io/) 6. 码云封面人物是一档用来展示码云会员风采的栏目 [https://gitee.com/gitee-stars/](https://gitee.com/gitee-stars/)