ssm+easyUI datagrid 不能显示后台controller层返回的json数据
Posted 极限森林
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了ssm+easyUI datagrid 不能显示后台controller层返回的json数据相关的知识,希望对你有一定的参考价值。
后台打印查询出来的数据:
{"total":29,"rows":[{"department_id":0,"department_name":"董事会办公室","id":1,"idcard":"3423243543534","phone":"15155157074","rname":"汪海燕","sex":1,"uname":"wanghaiyan"},{"department_id":0,"department_name":"院长办公室","id":2,"idcard":"4354565723424","phone":"15856989071","rname":"徐瑶洁","sex":1,"uname":"xuyaojie"},{"department_id":0,"department_name":"人力资源部","id":3,"idcard":"2343543543645654","phone":"18856980711","rname":"雷柏吉","sex":0,"uname":"leibaiji"},{"department_id":0,"department_name":"国际交流中心","id":4,"idcard":"789724389389236576","phone":"18009691880","rname":"胡晓姣","sex":1,"uname":"huxiaojiao"},{"department_id":0,"department_name":"党委办公室","id":5,"idcard":"897572637462834","phone":"13856936979","rname":"李薇薇","sex":1,"uname":"liweiwei"},{"department_id":0,"department_name":"教务处","id":6,"idcard":"7623864723627384","phone":"13856515372","rname":"高春香","sex":1,"uname":"gaochunxiang"},{"department_id":0,"department_name":"学生处","id":7,"idcard":"234235435435345","phone":"13033080925","rname":"王建新","sex":0,"uname":"wangjianxin"},{"department_id":0,"department_name":"团委","id":8,"phone":"13856888038","rname":"唐阳","sex":0,"uname":"tangyang"},{"department_id":0,"department_name":"招生就业处","id":9,"phone":"18705601914","rname":"戴世静","sex":1,"uname":"daishijing"},{"department_id":0,"department_name":"工会","id":10,"phone":"13866726653","rname":"王娜","sex":1,"uname":"wangna"}]}
前台代码:
$(function() {
$(‘#Employee_datagride‘).datagrid({
url : ‘employee/list.action‘,
fit:false,
frozen:true,
striped:true,
fitColumns : true,
rownumbers:true,
border : false,
nowrap : true,
singleSelect:false,
pagination : true,
pagePosition : ‘bottom‘,
pageSize : 10,
pageList : [ 10, 15, 20 ],
idField : ‘id‘,
sortName : ‘id‘,
sortOrder : ‘desc‘,
columns : [[{
title :‘编号‘,
field :‘id‘,
width : 50,
checkbox: true
},{
title :‘登录名‘,
field :‘uname‘,
width : 100
},{
title :‘真实姓名‘,
field :‘rname‘,
width : 100
},{
title :‘性别‘,
field :‘sex‘,
width : 50
},{
title :‘联系方式‘,
field :‘phone‘,
width : 150
},{
title :‘身份证号‘,
field :‘idcard‘,
width : 150
},{
title :‘所在部门‘,
field :‘department_name‘,
width : 100
}]],
toolbar:[{
id:‘btn_report‘,
text:‘添加‘,
iconCls:‘icon-add‘,
handler:function(){
employee_add();
}
},{
id:‘btn_report‘,
text:‘删除‘,
iconCls:‘icon-remove‘,
handler:function(){
Employee_delete();
}
},{
id:‘btn_add‘,
text:‘修改‘,
iconCls:‘icon-edit‘,
handler:function(){
Employee_edit();
}
},{
id:‘btn_edit‘,
text:‘重置密码‘,
iconCls:‘icon-reload‘,
handler:function(){
}
}]
});
但是就是不能显示,在网上查了好多,都不知道什么原因,后来发现是jar造成的。用fastjson-1.2.7.jar就可以显示了
以上是关于ssm+easyUI datagrid 不能显示后台controller层返回的json数据的主要内容,如果未能解决你的问题,请参考以下文章
在使用easyui,datagrid时,JSON中的如果含有换行符,则不能显示数据
EasyUI 解决 datagrid 中 NumberBox 限制小数位数后不能输入小数点问题
easyui datagrid设置fit: true后,页面显示不全的情况
EasyUI 使用tabs切换后datagrid显示不了内容