springboot分页查询
springboot分页查询的配置及实现
common包中配置类
在common中新建一个mybatisplus配置类,配置代码为
@Configuration
public class MybatisPlusConfig {
@Bean
public PaginationInterceptor paginationInterceptor() {
PaginationInterceptor paginationInterceptor = new PaginationInterceptor();
return paginationInterceptor;
}
}
业务层直接new使用
/*分页查询*/
QueryWrapper<ItCxcxVehInfo> itCxcxVehInfoWrapper = new QueryWrapper();//新建一个分页查询
itCxcxVehInfoWrapper.eq("vehBrand","2");//查询条件
Page<ItCxcxVehInfo> page = new Page(1, 3);//分页条件
page = itCxcxVehInfoDAO.selectPage(page,itCxcxVehInfoWrapper);//开始按条件查询
if (null == page || null == page.getRecords() || 0 == page.getRecords().size()) {
return null;
}
System.out.println(page.getRecords());
List<ItCxcxVehInfo> loadByVehInfo = page.getRecords();//取得查询结果