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 ...
随机推荐
- [JZOJ 5804] 简单的序列
思路: 似乎和某次培训的题很像啊... 将左括号记为1,右括号记为-1,那么最终一定加和为0,然后再求最小前缀和. 用dp解决即可. #include <bits/stdc++.h> us ...
- hdu多校第一场1004(hdu6581)Vacation 签到
题意:有n+1辆车,每辆车都有一定的长度,速度和距离终点的距离,第1-n辆车在前面依次排列,第0辆车在最后面.不允许超车,一旦后车追上前车,后车就减速,求第0辆车最快什么时候能到达终点? 思路:对于每 ...
- 【转】tomcat系统架构分析
https://blog.csdn.net/wsl211511/article/details/51622991
- vue 报错:Cannot read property '__ob__' of undefined
我的原因:引入组件后未注册 <script> import ComFirst from "../../components/ComFirst.vue" import C ...
- redis随记
CONFIG REWRITE 将config文件 将服务器当前所使用的配置记录到 redis.conf 文件中.
- 天才ACM
天才ACM 给定一个整数m,定义一个集合的权值为从这个集合中任意选出m对数(不够没关系,选到尽可能选,凑不成对的舍去),每对数两个数的差的平方的和的最大值. 现在给出一个数列\(\{a_i\}\),询 ...
- leetcood学习笔记-55-跳跃游戏
题目描述: 第一次提交: class Solution: def canJump(self, nums: List[int]) -> bool: if len(nums)<=1: retu ...
- JQUERY(入口函数 选择器)
入口函数 $(document).ready(function(){ });可以简写为$(function(){}) 选择器 基本选择器 元素选择器 $("p") 所有 & ...
- undertow服务器
参考地址:http://undertow.io/undertow-docs/undertow-docs-1.3.0/index.html 1.引入相关jar <dependencies> ...
- Flask扩展 -- flask-mail
电子邮件是最常用的通信方式之一.虽然Python标准库中的smtplib包可用在Flask程序中发送电子邮件,但包装了smtplib的Flask-Mail扩展能更好的和Flask集成. 1.安装Fla ...