springboot + mybatis plus + page分页

pom.xml


	com.baomidou
	mybatis-plus-boot-starter
	3.1.1

配置类:

@Configuration
public class MybatisPlusConfig {

    /**
     * 分页插件
     */
    @Bean
    public PaginationInterceptor paginationInterceptor() {
        return new PaginationInterceptor();
    }
}

controller:

@RequestMapping(value = "/page",method = RequestMethod.POST)
public IPage page(int pageNum, int pageSize, MpUser mpUser){
    Page page = new Page<>(pageNum,pageSize);
    return mpUserService.selectPageExt(page,mpUser);
}

iService:

IPage selectPageExt(Page page, MpUser user);

serviceImpl:

@Override
public IPage selectPageExt(Page page, MpUser user) {
    List lists = mpUserMapper.selectPageExt(page, user);
    return page.setRecords(lists);
}

mapper:

@Select("")
    List selectPageExt(Page page, @Param("user") MpUser user);

测试结果:

springboot + mybatis plus + page分页_第1张图片

参考:https://blog.csdn.net/sinat_34338162/article/details/83543994

你可能感兴趣的:(springboot)