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. ORACLE 利用 REPLACE函数替换字段字符串

    REPLACE(string,s1,s2) string 希望被替换的字符或变量 s1 被替换的字符串 s2 要替换的字符串 SQL> select replace(he love you,he ...

  2. Linux的一些基本概述以及系统使用

    GNU:项目名称(意指开发在类UNIX系统上的软件).POSIX:可移植(Portable)操作系统接口,便于程序在不同操作系统上运行. Linux是符合POSIX标准的操作系统: 完全兼容POSIX ...

  3. POJ 2391 Ombrophobic Bovines

    Ombrophobic Bovines Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 18623   Accepted: 4 ...

  4. [LeetCode] Construct Binary Tree from Inorder and Postorder Traversal 由中序和后序遍历建立二叉树

    Given inorder and postorder traversal of a tree, construct the binary tree. Note: You may assume tha ...

  5. 捕获起英文名Edda的灵感来源,我的心愿是程序员这个行业能够男女人数平衡

    在腾讯的暑期训练营结识过不少鹅厂的前辈,他们对我的成长提供了很大的帮助,可以说有着知遇之恩,大部分现在还保持着联系,请教问题时会不吝赐教,以至于就在前两天11号企鹅18岁的成年礼,朋友圈刷满了领腾讯总 ...

  6. Android开发之应用程序的安装

    这里介绍的是用XUtils下载apk文件,然后进行安装. 首先用HttpUtils下载文件(记得获取SD卡的读写权限和联网的权限): /** * 下载Apk */ private void downL ...

  7. 尝试在你浏览器的Console(F12)中运行一下,你会发现页面被不同的颜色块高亮了(css调试中学到的js)

    现在到处都是JavaScript,每天都能知道点新东西.一旦你入了门,你总能从这里或是那里领悟到很多知识. 一旦我发现一些有意思的东西,我喜欢去感觉他们的源代码,看一看它是怎么办到的. 今天我想分享A ...

  8. Android基础总结(四)

    网络图片查看器 确定图片的网址 发送http请求 URL url = new URL(address); //获取连接对象,并没有建立连接 HttpURLConnection conn = (Http ...

  9. 【codeforces 148D】 Bag of mice

    http://codeforces.com/problemset/problem/148/D (题目链接) 题意 包中有w个白鼠,b个黑鼠.公主和龙轮流画老鼠,公主先画,谁先画到白鼠谁就赢.龙每画完一 ...

  10. 一个将 footer 保持在底部的最好方法

    原文: Quick Tip: The Best Way To Make Sticky Footers 当你在布局网页时,有可能会遇到类似下面的这种情况 导致这一问题的原因是页面内容太少,无法将内容区域 ...