easyuUI实现客户分页显示逻辑分析
2024-09-02 21:59:03
页面
前端
前端easyUI,自带分页功能,添加pagination属性
前端会传给后端两个属性:
- page:当前页码
- rows:每页显示记录数
后端
- 接收page和rows参数
- 根据参数分页查询
- 获取结果
- 返回给页面(total:总记录数;rows:当前页数据列表)
后台使用pageHelper分页插件
- 导入pagehelper-5.1.2.jar及依赖jar包jsqlparser-1.0.jar
- 在applicationContext.xml配置注册pagehelper插件
使用easyui的datagrid分页时遇到的错误
错误描述:
严重: Servlet.service() for servlet [DispatcherServlet] in context with path [/CRM] threw exception [Request processing failed; nested exception is org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.exceptions.PersistenceException:
### Error querying database. Cause: java.lang.NullPointerException
### Cause: java.lang.NullPointerException] with root cause
java.lang.NullPointerException
at com.github.pagehelper.PageInterceptor.intercept(PageInterceptor.java:147)
at org.apache.ibatis.plugin.Plugin.invoke(Plugin.java:61)
解决方法
/**
* 查询分页数据,给页面返回json格式数据
*
* @return
*/
@ResponseBody
@RequestMapping("/listByPage")
public Map<String, Object> listByPage(Integer page, Integer rows) {
PageHelper.startPage(page, rows);
List<Customer> list = customerService.selectList();
// 使用PageInfo封装查询结果
PageInfo<Customer> pageInfo = new PageInfo<>(list);
// 从PageInfo对象中取出查询结果
long total = pageInfo.getTotal();
List<Customer> custList = pageInfo.getList();
map.put("total", total);
map.put("rows", custList);
return map;
}
将从pageInfo中取得的的结果存入map时,将对应的结果(custList)的键改为rows,如果不是rows,可能会报此错误。
最新文章
- eclipse下创建maven项目
- dsfgsdfg
- css中font-size的单位总结:px、em、pt
- oracle如何获取每个月的最后一天
- Linux中环境变量文件及配置(转载)
- OGNL表达式(待解答)
- 50 Android Hacks阅读笔记
- easyui的datagrid实例实现
- sky A800s手机恢复出厂设置操作
- bzoj 4278 [ONTAK2015]Tasowanie(SA,贪心)
- 转摘:常用ubuntu 关机,重启,注销命令
- 在Delphi中,关于数组名称
- 结构体dict_index_t;
- 从键盘输入当月利润I,求应发放奖金总数?
- input、button、a标签 等定义的按钮尺寸的兼容性问题
- navcat无法远程连接mysql数据库解决办法
- 《JAVA程序设计》_第四周学习总结
- JQuery的常用选择器 转
- zabbix3监控php-fpm的状态
- Shell 脚本格式注意事项
热门文章
- 3、Shiro授权
- 让hibernate支持mysql的text或者longtext
- 阶段3 1.Mybatis_05.使用Mybatis完成CRUD_3 Mybatis的CRUD-修改和删除操作
- 测开之路一百二十八:flask之重定向和404
- Service层获取HttpServletRequest request
- HTML——超级链接 表格 框架
- idea中怎么去查看maven项目的依赖包是否有冲突
- vue2.0父子组件通信以及同级组件通信
- 第十三周学习总结 Java的异常
- qt undefined reference to `vtable for subClass&#39;