Closed youapple closed 6 years ago
SELECT count(0) FROM T 值为3,但是结果中的total显示的是我的当前分页的记录数,这个要怎样设置?谢谢大神!
@duweili SQL日志有没有检查过?确定经过分页了吗?
@duweili 这个问题解决了吗?我这里也是这个问题,检查打印的sql,确认分页了。但是total是当前页的记录数。
@abel533 配置文件配置方言就好了。 pagehelper.dialect=com.github.pagehelper.dialect.helper.OracleDialect 但是,配置方言以后,列表就没有分页了。
@duweili 我也是这个问题 同问
@duxiaolong 用了dubbo了是吗 我这个问题解决了 分页没有问题了
怎么解决呢?加了dialect: com.github.pagehelper.dialect.helper.MySqlDialect,就不分页了 { "code": 1, "msg": "成功", "data": { "pageNum": 1, "pageSize": 18, "size": 18, "startRow": 0, "endRow": 17, "total": 18, "pages": 1,
@huzhixiang 不应该配置 dialect,应该是 helperDialect,文档有说明。
无论怎么修改配置,查询总是全部数据,拦截不生效(springboot的使用)
@githupwangyu 看日志SQL对不对。。spring boot情况下,只需要引入Starter就能用。
遇到同样的问题,各种配置无果后,发现代码寄几写的有问题。是PageInfo构造参数传了List实例的原因,一定要传Page实例
解决方案:
Page
查看了源码才知道:
public PageSerializable(List
@GithubXie40 不是你说的这样,通过分页插件处理后的结果,表面上是 List 类型,实际是 Page( extends ArrayList
)。只有不是经过分页,或者你自己对结果处理后再用 PageInfo,才没有 total。
注意 java8 lambda 处理后的流会丢失分页信息。
在lambda之前,先搞一个pageinfo, lambda之后,把分页信息copy进去 @
`
List
List<BaseRequirementResp> baseRequirementResps = requirementObjs.stream().map(o-> new BaseRequirementResp(o)).collect(Collectors.toList());
PageInfo<BaseRequirementResp> pageInfo = new PageInfo<>(baseRequirementResps);
BeanUtils.copyProperties(origPageInfo,pageInfo,"list");
`
哈哈哈......
我的也是total总是等于pageSize,如果使用lamada的话,数据确实会丢失
怎么解 我也遇到了
在lambda之前,先搞一个pageinfo, lambda之后,把分页信息copy进去 @
` List requirementObjs= requirement.getRequirements(currentPage,pageSize); PageInfo origPageInfo = new PageInfo<>(requirementObjs);
List<BaseRequirementResp> baseRequirementResps = requirementObjs.stream().map(o-> new BaseRequirementResp(o)).collect(Collectors.toList()); PageInfo<BaseRequirementResp> pageInfo = new PageInfo<>(baseRequirementResps); BeanUtils.copyProperties(origPageInfo,pageInfo,"list");
` 这样可以用, 结果没问题
total 是总记录数,不是当前页。