springboot中pageHelper插件 list设置不进去 为null
分页pageHelper中list放不进去值 为null,可能的解决方案如下:
1.
注意代码顺序,PageHelper.startPage(pageNumber,pageSize)要放在查询List的前面
代码如下:
PageHelper.startPage(pageNumber,pageSize);
List<User> list=userMapper.selectAll(map);
2.PageBean的泛型不加
比如:PageBean info=new PageBean(list);
@RequestMapping(value = "/getList7",method = RequestMethod.GET)
@ResponseBody
public PageBean getList7(@ApiParam(name ="pageNumber",value = "页码",defaultValue = "1",required = true)int pageNumber,
@ApiParam(name ="pageSize",value = "条数",defaultValue = "10",required = true)int pageSize,
@ApiParam(name ="sortName",value = "排序名称")String sortName,
@ApiParam(name ="sortOrder",value = "排序方式")String sortOrder,
HttpServletRequest request) {
Map map=request.getParameterMap();
if(StringUtils.isNotBlank(sortName) && StringUtils.isNotBlank(sortOrder)){
PageHelper.orderBy(CommonUtil.camel2Underline(sortName)+" "+sortOrder);
}else{
PageHelper.orderBy("id desc");
}
PageHelper.startPage(pageNumber,pageSize);
List<User> list=userMapper.selectAll(map);
PageBean info=new PageBean(list);
return info;
3.pageInfo中的值再设置一遍,往pageBean中强制设置值
PageHelper.startPage(pageNumber,pageSize);
List<User> list=userMapper.selectAll(param);
PageBean<User> info = new PageBean<>(list);
info.setTotal(new PageInfo(list).getTotal());
info.setPageNumber(pageNumber);
info.setPageSize(pageSize);
info.setRows(list);
info.setPages(new PageInfo(list).getPages());
info.setSize(new PageInfo(list).getSize());
return info; 4.注意分页中不能有多个mapper查询List 会以第一个查询分页
springboot中pageHelper插件 list设置不进去 为null的更多相关文章
- SpringBoot Mybatis PageHelper插件报错
SpringBoot2.0.0 MyBatis1.3.2 PageHelper1.1.2插件,但是在启动运行时,抛错:org.springframework.beans.factory.BeanCre ...
- springboot集成pagehelper插件
1.在pom.xml中引入依赖 <dependency> <groupId>com.github.pagehelper</groupId> <artifact ...
- IDEA 中javadoc插件不能设置的问题
解决方案 1.手动下载插件 https://github.com/ranzou06/intellij-javadocs/blob/master/intellij-javadocs.zip?raw=tr ...
- VS Code中Matlab插件安装设置
Install the extension in VS Code Open the command palette using Ctrl+Shift+P Type ext install Matlab ...
- springboot结合mybatis使用pageHelper插件进行分页查询
1.pom相关依赖引入 <dependencies> <dependency> <groupId>org.springframework.boot</grou ...
- SpringBoot集成PageHelper时出现“在系统中发现了多个分页插件,请检查系统配置!”
近日在项目中使用SpringBoot集成PageHelper后,跑单元测试时出现了"在系统中发现了多个分页插件,请检查系统配置!"这个问题. 如下图所示: org.mybatis. ...
- SpringBoot中Mybaties PageHelper插件使用
首先引入pom.xml文件配置 <!-- mybatis --> <dependency> <groupId>org.mybatis.spring.boot&l ...
- springboot中的mybatis是如果使用pagehelper的
springboot中使用其他组件都是基于自动配置的AutoConfiguration配置累的,pagehelper插件也是一样的,通过PageHelperAutoConfiguration的,这个类 ...
- Mybatis中使用PageHelper插件进行分页
分页的场景比较常见,下面主要介绍一下使用PageHelper插件进行分页操作: 一.概述: PageHelper支持对mybatis进行分页操作,项目在github地址: https://github ...
随机推荐
- icmp隧道--icmpsh
本地:ubantu 目标主机:windows 在ubantu上关闭自带的icmp回应 sysctl -w net.ipv4.icmp_echo_ighore_all=1 ubantu上启动 pip i ...
- 顺时针打印矩阵元素(python实现)
我觉得我的算法比较简单易懂,比网上的那些简单些.至于时间复杂度就没有比较了. 算法思想:从最外层向内层遍历矩阵 # my algorithmimport math def print_matrix(m ...
- SSM 整合 Shiro
1. 导包 <!-- spring --> <dependency> <groupId>org.springframework</groupId> &l ...
- jupyter安装_pip法
安装jupyter notebook的流程(注意python至少需要3.6版本) python -m pip install jupyter #安装jupyter python -m pip ins ...
- 11-MySQL-Ubuntu-数据表中数据的删除(四)
数据的删除(delete) (1)物理删除(不可逆,公司不会采取这种方法,如现在一般不会出现注销,数据具有无限价值) 删除整张表的数据!!! delete from 表名; 删除部分给定条件的数据: ...
- GNU 交叉工具链的介绍与使用
常用工具介绍 名称 归属 作用 armlinuxas binutils 编译 ARM 汇编程序 armlinuxar binutils 把多个.o 合并成一个.o 或静态库(.a) arml ...
- boost相关函数
1.boost::scoped_ptr是一个比较简单的智能指针,它能保证在离开作用域之后它所管理对象能被自动释放 #include <iostream> #include <boos ...
- python 模块间的引入
转载来自: https://www.cnblogs.com/whitemouseV2-0/p/9925344.html https://www.cnblogs.com/whitemouseV2-0/p ...
- System.arraycopy复制数组方法解释
**/* * @param src the source array.源数组 * @param srcPos starting position in the source array.源数组要复制的 ...
- leetcode-47-全排列②
题目描述: 方法一:回溯 class Solution: def permuteUnique(self, nums: List[int]) -> List[List[int]]: #nums = ...