Springboot+Mybatis+PageHelper 分页、排序

匿名 (未验证) 提交于 2019-12-02 23:05:13
版权声明:本文为博主原创文章,转载请附上博文链接! 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
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!