springboot 以及mybatis-plus 整合 Element-admin 实现分页效果。

mybatis-plus 的使用!
1.引入pom文件
<dependency>
    <groupId>com.baomidou</groupId>
    <artifactId>mybatis-plus-boot-starter</artifactId>
    <version>3.0.5</version>
</dependency>

 

 
2.记得修改application.yml文件。
3.
对于 User表 可能要进行表的对应。
@TableName ( value = "t_user" )
写在类的上面。
@TableField ( value = "phonecode" )
字段对应。
4.在dao 文件中 要继承 BaseMapper
 
1后端代码 
 controller层 
@Autowired
private UserDao userDao;
@GetMapping("getList")
public IPage<User> getList(@RequestBody @RequestParam(value = "page") int page,@RequestBody @RequestParam(value = "limit")int limit){
    IPage<User> page1 = new Page<>(page,limit);
    IPage<User> userIPage = userdao.selectPage(page1,null);
    return userIPage;
}

 

2.前端代码
 
首先在表格之下加入分页条。
<pagination v-show="total>0" :total="total" :page.sync="listQuery.page" :limit.sync="listQuery.limit" @pagination="getList" />

 

然后 在scrpit
import Pagination from '@/components/Pagination' // secondary package based on el-pagination

 

然后再 element-admin-master中的components 下找到 Pagination 
导入到本项目 的 components  下。
然后 因为Pagination 中缺少这个js文件。
所以要在 element-admin-master 的 config 中找到这个js文件到如到该项目的config中。
接下来就可以开始使用了!
 
在index 中添加以下代码
components: { Pagination },
total: 0,
listQuery: {
page: 1,
limit: 10,   //limit注意 一定要为10
},
},
然后 
 
 
getList(){
  var _this = this;
  this.$http.get("http://localhost:8989/users/user/getList?page="+_this.listQuery.page+"&limit="+_this.listQuery.limit).then((res) => {
      this.users = res.data.records
      this.total = res.data.total
    })
},
//这样就完成了分页的效果!
 
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
本项目使用 Spring Boot 搭建, 用于加深对 Spring Boot 与 Shiro 的学习, 项目特色是支持 restful 风格权限控制, 支持对同一 URL, 不同 HTTP Mehtod 的权限控制, 适用于更多的场景. 预览地址: http://ewt.186g.cn 默认管理员账号: admin, 密码: 123456. 普通用户账号: user, 密码: 123456. 为了不影响其他人的浏览体验, 请尽量不要进行删除类的敏感操作. admin 为超级管理员, 自动拥有全部权限. 系统特色 支持根据同 URL, 不同 HTTP Method 来校验权限, 更支持 restful 场景. 集成 OAuth2 登录, 且提供了接口易于拓展开发. 全局异常处理. 根据请求方式区分返回 json 数据还是错误页面. Logback MDC 支持, 将当前登录人和操作者 IP 加入日志中. JSR-303 数据校验 运行环境 JDK 1.8 MySQL 5.7 Redis 配置文件 打开 application.properties 修改 MySQL 和 Redis 连接信息. spring.redis.host=127.0.0.1 spring.redis.port=6379 spring.cache.type=redis spring.datasource.username=root spring.datasource.password=123456 spring.datasource.url=jdbc:mysql://127.0.0.1:3306/shiro_action?useSSL=false&characterEncoding=UTF8 启动项目 在完成了上述步骤后,找到 ShiroActionApplication 启动类, 启动即可. 启动后访问地址为:http://localhost:8080 , 用户名:admin, 密码:123456. 技术选型 前端 前端框架: Layui 后台模板: Z-Admin 后端 SpringBoot 2.2.3.RELEASE Shiro 1.4.0 Mybatis-Plus3.1.2 Druid 1.1.10 PageHelper 1.2.9 Shiro-Redis 3.2.3
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值