JQGrid中未加载Json响应

JQGrid中未加载Json响应,jqgrid,struts2,Jqgrid,Struts2,我尝试了解决这个问题的方法。但它仍然不起作用。我觉得JSON响应的格式不对 在struts2中实现了JQGrid。在struts.xml中创建一个用户列表,并使用结果类型作为json返回json类型 这是我获得的Json {"JSON":"success","userList":[{"fName":"abi","lName":"babu"},{"fName":"abi1","lName":"babu1"},{"fName":"abi2","lName":"babu2"},{"fName":"ab

我尝试了解决这个问题的方法。但它仍然不起作用。我觉得JSON响应的格式不对

在struts2中实现了JQGrid。在struts.xml中创建一个用户列表,并使用结果类型作为json返回json类型

这是我获得的Json

{"JSON":"success","userList":[{"fName":"abi","lName":"babu"},{"fName":"abi1","lName":"babu1"},{"fName":"abi2","lName":"babu2"},{"fName":"abi3","lName":"babu3"},{"fName":"abi4","lName":"babu4"},{"fName":"abi5","lName":"babu5"},{"fName":"abi6","lName":"babu6"}]}
JSP页面是

 <script type="text/javascript">
    $(function () {
        'use strict';
        $("#datagrid").jqGrid({
            url: "json-table",
            datatype: "json",
            colNames:['fName','lName'],
            colModel:[
                {name:'fName',index:'fName', key:true, width:100,editable:true,editoptions:{size:10}},
                {name:'lName',index:'lName', width:100,editable:true},
            ],
            rowNum:10,
            rowList:[3,6],
            loadonce: true,
            pager: '#navGrid',
            sortname: 'fName',
            sortorder: "asc", 
            height: "auto", //210,
            width:600,
            onSelectRow: function(id) {
                var getID = $(this).jqGrid('getCell', id, 'fName');
            },
            viewrecords: true,
            caption:"JQ GRID"
        });
    });
</script>

$(函数(){
"严格使用",;
$(“#数据网格”).jqGrid({
url:“json表”,
数据类型:“json”,
colname:['fName','lName'],
colModel:[
{name:'fName',index:'fName',key:true,width:100,edit:true,editoptions:{size:10},
{name:'lName',index:'lName',宽度:100,可编辑:true},
],
rowNum:10,
行列表:[3,6],
有一次:是的,
寻呼机:“#导航网格”,
sortname:'fName',
分拣员:“asc”,
高度:“自动”,//210,
宽度:600,
OnSetrow:功能(id){
var getID=$(this).jqGrid('getCell',id,'fName');
},
viewrecords:是的,
描述:“JQ网格”
});
});

任何帮助都将不胜感激。谢谢。

您只需包含与输入数据格式对应的
jsonReader
参数即可:

jsonReader:{root:“userList”,repeatitems:false}