easyui列表查询报错:Cannot read property 'length' of undefined
来源:互联网 发布:腾讯云主机 绑定域名 编辑:程序博客网 时间:2024/06/10 09:34
1.问题描述
easyui中datagrid执行loadData方法出现如下异常:Cannot read property 'length' of undefined
2.一开始怀疑是js或者页面的问题,然后从早上干到下午,网上各种方法用尽了就是不行!
最后发现规律了:
使用mybatis从数据库查询返回的List不报错,但是自己new的ArrayList总是报错!
后来发现原来mybatis返回的不是ArrayList!而是PageList!
3.解决问题
PageList中有个参数Paginator包含了page(当前页), limit(每页显示条数), totalCount(总记录数),但是ArrayList就没有这个参数了。
PageList是ArrayList的子类!
知道了原因,就好办了!把你new的ArrayList改成PageList!代码如下:
原代码:
List<MsgInfo> list=new ArrayList<MsgInfo>();修改后代码:
Paginator paePaginator=new Paginator(page, pageSize, totalCount); List<MsgInfo> list=new PageList<MsgInfo>(paePaginator);然后return list;
大功告成!
4.答题解惑
可能你用浏览器查看返回的json数据时看不到page(当前页), limit(每页显示条数), totalCount(总记录数)这些信息,但是easyUI能解析到!
原因可能是因为浏览器任务这些信息类似于请求的头信息一样直接过滤了所以你看不到,但是会返回给easyUI!
手打半天,以惠后人!
1 0
- easyui列表查询报错:Cannot read property 'length' of undefined
- easyui列表查询报错:Cannot read property 'length' of undefined
- 解决jquery报错cannot read property 'length' of undefined
- react native 报错:cannot read property 'length' of undefined
- jQuery EasyUI 报错:Cannot read property length of XXX
- easyui中datagrid显示数据的时候报Cannot read property 'length' of undefined
- easyui reload方法报Cannot read property 'options' of undefined
- Cannot read property 'length' of undefined
- easyui防止重复提交及进度条报错解决: Cannot read property 'onClose' of undefined
- 日常-关于“Cannot read property 'length' of null”报错
- sencha touch报错 Cannot read property 'apply' of undefined
- vue报错 vue Cannot read property ‘ob’ of undefined
- 解决dataTable 报错:cannot read property "style" of undefined
- Angularjs报错:TypeError: Cannot read property 'slice' of undefined
- Uncaught TypeError: Cannot read property 'length' of undefined
- Uncaught TypeError: Cannot read property 'length' of undefined
- Uncaught TypeError Cannot read property 'length' of undefined
- JQUERY提示Cannot read property 'length' of undefined
- iOS解决两个静态库的冲突 duplicate symbol
- linux下离线更新nessus漏洞插件的方法
- APKTool使用方法
- blob类型转字符串
- 你不得不知道的:关于TnPM的定位问题
- easyui列表查询报错:Cannot read property 'length' of undefined
- BZOJ 4010: [HNOI2015]菜肴制作|拓扑排序贪心
- 关于ARGB_8888、ALPHA_8、ARGB_4444、RGB_565的区别
- CSS学习摘记
- 第二章Spring资源和配置开发环境-第一节spring资源网址 spring官网 eclipse插件 Spring jar包下载
- android greenDao(二)
- Ambiguous source files
- 时间戳转时间
- javaEE之------ApectJ的切面技术===标签