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. Doctype作用?严格模式与混杂模式如何区分?它们有何意义?

    怪异模式和严格模式(译注:一般称为标准模式:Standards Mode,下文中的严格模式都可以理解为标准模式)是浏览器解析CSS时的两种‘模式’.这篇文章将简单阐述这两种模式之间的差异. 译注:一个 ...

  2. BZOJ 1001: [BeiJing2006]狼抓兔子

    1001: [BeiJing2006]狼抓兔子 Time Limit: 15 Sec  Memory Limit: 162 MBSubmit: 20029  Solved: 4957[Submit][ ...

  3. JSP九大内置对象及四个作用域

    九大对象: 内置对象(又叫隐含对象,有9个内置对象):不需要预先声明就可以在脚本代码和表达式中随意使用 1-out: javax.servlet.jsp.JspWriter类型,代表输出流的对象.作用 ...

  4. windows批处理运行java程序

    明确需求 今天你编了一个java swing版照片查看器,想让计算机上的所有照片默认打开方式都改成你的照片查看器. 使用工具软件 很多工具软件都是不把jre打包到exe中的,这就是说打包之后的exe只 ...

  5. hibernate通过注解实现实体和表的映射

    参考: 表名的映射: //代表此类参与ORM映射,此注解必须要有 @Entity //代表user这个类映射了一个表user50,如果表名和类名一样,此注解可以省略 @Table(name=" ...

  6. iOS学习-UIButton的imageView和titleLabel

    UIButton的imageView和titleLabel的位置设置通过setImageEdgeInsets和setTitleEdgeInsets来设置 参考:http://blog.csdn.net ...

  7. NodeJs入门学习(一)

    NodeJs是针对前端工程师向web后端深入理解的一门很好的语言. 首先,记录NodeJS几大特性,后续补充: 一.Node.js 是单进程单线程应用程序,但是通过事件和回调支持并发,所以性能非常高. ...

  8. 递推 hdu 1330

    http://www.cnblogs.com/rainydays/archive/2013/01/16/2862235.html 看样例的答案 #include<stdio.h> #inc ...

  9. [转]如何循序渐进向dotnet架构师发展

    微软的DotNet开发绝对是属于那种入门容易提高难的技术.而要能够成为DotNet架构师没有三年或更长时间的编码积累基本上是不可能的.特别是在大 型软件项目中,架构师是项目核心成员,承上启下,因此RU ...

  10. jQuery_mobile页面跳转事件学习

      <html>     <head>         <meta http-equiv="Content-Type" content="t ...