栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Java

mybatis-plus+springboot+vue+element-ui实现分页

Java 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

mybatis-plus+springboot+vue+element-ui实现分页

第一步导入依赖


        
            com.github.pagehelper
            pagehelper
            5.2.0
        
        

            
            com.baomidou
            mybatis-plus-boot-starter
            3.2.0
        

然后导入前端element-ui组件+html代码

    
    
    
序号 租车人 客户性别 联系方式 销售负责人 家庭住址 租车车型 租车时间 支付金额 还车时间 租车状态 操作
{{ item.id}} {{ item.renCarPerson}} {{ item.cusSex}} {{ item.cusMobile}} {{item.saleId}} {{ item.cusAddress}} {{ item.rentCarType}} {{ item.rentCarTime.substring(0,16).replace("T"," ")}} {{ item.payMoney}} {{ item.returnCarTime.substring(0,16).replace("T"," ")}} {{ item.rentCarState}}
后端代码

mybatis-plus配置文件

import com.baomidou.mybatisplus.extension.plugins.PaginationInterceptor;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

//mybatis-plus分页插件
@Configuration
@ConditionalOnClass(value = {PaginationInterceptor.class})
public class MybatisPlusConfig {

    @Bean
    public PaginationInterceptor paginationInterceptor() {
        PaginationInterceptor paginationInterceptor = new PaginationInterceptor();
        return paginationInterceptor;
    }
}

mapper层

public interface InventoryMapper extends baseMapper {
    //分页
    public Page findByPageService(int pageCode, int pageSize);
}

service层

public interface InventoryService extends IService {
    //分页
    public Page findByPageService(int pageCode, int pageSize);
}

serviceImpl层

@Service
public class InventoryServiceImpl extends ServiceImpl implements InventoryService{
  @Resource
    InventoryMapper inventoryMapper;

    @Override
    public Page findByPageService(int pageCode, int pageSize) {
        //1.创建Page对象,传入两个参数:当前页和每页显示记录数
        Page page = new Page(pageCode,pageSize);
        //2.将分页查询到的所有数据封装到Page对象中
        inventoryMapper.selectPage(page,null);
        return page;
    }
}

最后controller层

    //    分页
    @RequestMapping(value = "/pagehelper/{pageCode}/{pageSize}",method = RequestMethod.GET)
    @ResponseBody
    public Page findByPage(@PathVariable(value = "pageCode") int pageCode, @PathVariable(value = "pageSize") int pageSize) {
        System.out.println(pageCode+"...."+pageSize);
        Page pageInfo = inventoryService.findByPageService(pageCode, pageSize);
//        System.out.println(pageInfo);
        return pageInfo;
    }

页面展示

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/336574.html

Java相关栏目本月热门文章

我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号