SpringBoot整合pagehelper分页插件用法

SpringBoot整合pagehelper分页插件用法

    *用到了JSONObject,PageInfo*。此外,appllication.yml文件无需另外配置。

1.添加pom依赖:

      
        
            com.github.pagehelper
            pagehelper-spring-boot-starter
            1.2.5
        

        
            com.alibaba
            druid
            1.1.2
        

2.Controller层:

        @PostMapping("/getList")
	public ResponseEntity getContens(@RequestBody JSONObject query){
		PageInfo                 
        list=contentManagementService.getList(query);
		return new ResponseEntity(list,HttpStatus.OK);
	}

3.Server层:

        public PageInfo getList(JSONObject query){
		Integer pageNum= query.getInteger("pageNum");
		Integer pageSize= query.getInteger("pageSize");
		PageHelper.startPage(pageNum, pageSize);
		List list= (List)     
        contentManagementMapper.getList(query);
		PageInfo pageInfo =new PageInfo 
        (list);
		return pageInfo;
	}

4.Mapper层:

List getList(JSONObject query);

mapper.xml里的SQI语句就不贴出来了,完~~~

 

你可能感兴趣的:(MyBatis,分页插件pagehelper)