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!代码如下:

原代码:

  1. List<MsgInfo> list=new ArrayList<MsgInfo>();

修改后代码:

  1. Paginator paePaginator=new Paginator(page, pageSize, totalCount);
  2. List<MsgInfo> list=new PageList<MsgInfo>(paePaginator);

然后return list;

4.答题解惑

可能你用浏览器查看返回的json数据时看不到page(当前页), limit(每页显示条数), totalCount(总记录数)这些信息,但是easyUI能解析到!

原因可能是因为浏览器任务这些信息类似于请求的头信息一样直接过滤了所以你看不到,但是会返回给easyUI。

原文链接:http://blog.csdn.net/xuxile/article/details/50548285

easyui Datagrid查询报错Uncaught TypeError:Cannot read property 'length' of undefined的更多相关文章

  1. js 报错 Uncaught TypeError: Cannot read property 'trim' of undefined

    jquery Uncaught TypeError: Cannot read property 'trim' of undefined 报错原因及解决方案 $.trim() 函数用于去除字符串两端的空 ...

  2. Vue 组件封装发布到npm 报错 Uncaught TypeError: Cannot read property 'toLowerCase' of undefined

    Uncaught TypeError: Cannot read property 'toLowerCase' of undefined 原因是 没有导出 export default { name:& ...

  3. 报错: Uncaught TypeError: Cannot read property 'prototype' of undefined(Day_43)

    报错原因 引入的js顺序错误,elementUI需要依赖于Vue,调整顺序即可. 调整后

  4. Datatable报错Uncaught TypeError: Cannot read property 'cell' of undefined

    使用Datatables时,报出错误 仔细想想,是因为我在columns里加入了id,并设置visible:false 但是却没在下面的HTML部分多加一个 th 虽然我觉得因为id是隐藏的,不用加上 ...

  5. easyui使用时出现这个Uncaught TypeError: Cannot read property 'combo' of undefined

    easyui使用时出现这个Uncaught TypeError: Cannot read property 'nodeName' of undefined 最后检查发现是必须给select一个id,光 ...

  6. vue项目使用echarts按需引入实现地图动态显示效果时,报错:TypeError: Cannot read property 'dataToPoint' of undefined

    vue项目使用echarts按需引入实现地图动态显示效果时,报错:TypeError: Cannot read property 'dataToPoint' of undefined 借鉴了该大神的文 ...

  7. 前台报错:Uncaught TypeError: Cannot read property '0' of null

    错误现象: var div1=mycss[0].style.backgroundColor;  //这一行提示360和chrome提示:Uncaught TypeError: Cannot read  ...

  8. vue报错 Uncaught TypeError: Cannot read property ‘children ’ of null

    Uncaught TypeError: Cannot read property ‘children ’ of null ratings未渲染完毕,就跳走goods了,取消默认跳转,即可

  9. vue报错 Uncaught TypeError: Cannot read property of null

    有可能是点击a标签,但是a标签有click事件,未阻止默认事件导致报错,开始都看不出来是什么错误

随机推荐

  1. ubuntu14.04 yuv文件的播放及视频信息的查看

    1.安装ffmpeg sudo add-apt-repository ppa:mc3man/trusty-media sudo apt-get update sudo apt-get install ...

  2. 解读ASP.NET 5 & MVC6系列(12):基于Lamda表达式的强类型Routing实现

    前面的深入理解Routing章节,我们讲到了在MVC中,除了使用默认的ASP.NET 5的路由注册方式,还可以使用基于Attribute的特性(Route和HttpXXX系列方法)来定义.本章,我们将 ...

  3. [LeetCode] Line Reflection 直线对称

    Given n points on a 2D plane, find if there is such a line parallel to y-axis that reflect the given ...

  4. [LeetCode] Count of Smaller Numbers After Self 计算后面较小数字的个数

    You are given an integer array nums and you have to return a new counts array. The counts array has ...

  5. jquery 监听常用监听方法

    最近在做网站开发,需要用到不少js的知识.之前学过现在重新来看,发现还真忘了不少~~ 在使用基于bootstrap,或者基于 jquery 的插件时,如过没有出现预期效果 请最先检查下是否优先载入的 ...

  6. DeepMind背后的人工智能:深度学习原理初探

    去年11月,一篇名为<Playing Atari with Deep Reinforcement Learning>的文章被初创人工智能公司DeepMind的员工上传到了arXiv网站.两 ...

  7. AngularJS模型

    1. AngularJS模型主要就是使用的AngularJS的ng-model指令. ng-model指令可以将输入域的值与 AngularJS 创建的变量绑定. <!DOCTYPE html& ...

  8. 在 Sublime Text 3 中配置编译和运行 Java 程序

    参考网址:http://www.open-open.com/lib/view/open1388105023765.html 1. 设置 java 的 PATH 环境变量 2. 创建批处理或 Shell ...

  9. js获取可视区域高度

    document.body.clientWidth ==> BODY对象宽度 document.body.clientHeight ==> BODY对象高度 document.docume ...

  10. COGS2531. [HZOI 2016]函数的美 打表+欧拉函数

    题目:http://cogs.pw/cogs/problem/problem.php?pid=2533 这道题考察打表观察规律. 发现对f的定义实际是递归式的 f(n,k) = f(0,f(n-1,k ...