版权声明:本文为博主原创文章,转载请附上博文链接! https://blog.csdn.net/csdnluolei/article/details/86671922
Springboot+Mybatis+PageHelper 分页、排序
<!-- 继承 spring boot 父包--> <parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>1.5.1.RELEASE</version> <relativePath/> <!-- lookup parent from repository --> </parent> <!-- springboot分页插件,pagehelper1.2.3与 springboot1.5不兼容 必须使用pagehelper的spring starter,才能无配置启动使用pagehelper,千万别引用错--> <dependency> <groupId>com.github.pagehelper</groupId> <artifactId>pagehelper-spring-boot-starter</artifactId> <version>1.2.2</version> </dependency>
方法一:PageHelper排序
String orderBy = "sort asc"; //PageHelper方法 (排序字段 空格 排序方式) PageHelper.startPage(page, size, orderBy); List<TbDictDetail> selectByExample = dictDetailMapper.selectByExample(null);
方法二:Mybatis排序
String orderBy = "sort asc"; //(排序字段 空格 排序方式) PageHelper.startPage(page, size, orderBy); TbDictDetailExample example = new TbDictDetailExample(); example.setOrderByClause(orderBy); //排序 List<TbDictDetail> selectByExample = dictDetailMapper.selectByExample(example);
文章来源: https://blog.csdn.net/csdnluolei/article/details/86671922