这个list集合中的数据已经测试了,可以取到
@RequestMapping(value="/findCost",method=RequestMethod.POST)
@ResponseBody
public Object findCost(HttpServletRequest request) throws Exception{
List costs= costService.findAll();
return costs;
}
有个一table id是dg,changeme为工程名,其中定义的列名都可以正常显示,但是post请求时报406错误,数据都不显示
$(function () {
$('#dg').datagrid(
{
url :'/changeme/findCost',
method : 'post',
title : '资费列表',
iconCls : 'icon-save',
loadMsg : '数据加载中,请稍后......',
fitColumns : true,
striped : true,
singleSelect : true,
rownumbers : true,
columns : [ [
{
field : 'id',
checkbox : true,
width : 10
},
{
field : 'name',
title : '资费名称',
width : 300,
},
{
field : 'baseDuration',
title : '基本时长',
width : 200,
sortable :true
},
{
field : 'baseCost',
title : '基本费用',
width : 200,
sortable :true
},
{
field : 'unitCost',
title : '单位费用',
width : 200,
sortable :true
},
{
field : 'createTime',
title : '创建时间',
width : 200
},
{
field : 'startTime',
title : '开通时间',
width : 200
},
{
field : 'status',
title : '状态',
width : 200,
formatter : function(value) {
if (value == "0") {
return "开通";
} else if (value=="1"){
return "暂停";
}else{
return null;
}
}
}
] ],
toolbar : [ {
text : '添加',
iconCls : 'icon-add',
handler : function() {
// 跳转到添加页面
$('#content').load('/addCost');
}
}, '-', {
text : '删除',
iconCls : 'icon-remove',
handler : function() {
// 跳转到添加页面
var index = $('#dg input:checkbox').value;
del(index);
}
}, '-', {
text : '修改',
iconCls : 'icon-edit',
handler : function() {
view();
}
}]
} );
} );
你先看下你springMVC 返回的json 数据的格式是否正确,是否跟easyui 的格式能正确的匹配上。
个人签名:[url=http://www.sdpretty.com]健康宝宝[/url]
[code="java"]YAHOO.util.Event.onDOMReady(function(){
var Event = YAHOO.util.Event;
window.moveTo(0,0);
window.resizeTo(screen.availWidth,screen.availHeight);
var dsOption ={
fields : [
{name : 'itemName'},
{name : 'contractRatifyDate',type:'date'},
{name : 'poNo'},
{name : 'rowItem'},
{name : 'materialNo'},
{name : 'materialDepict'},
{name : 'amount'},
{name : 'unit'},
{name : 'waitReplayAmount'},
{name : 'requireDate'},
{name : 'deliveryType'},
{name : 'shortAddress'},
{name : 'onWayAmount'},
{name : 'unDeliveryAmount'},
{name : 'providerCode'},
{name : 'providerName'},
{name : 'buyerId'},
{name : 'deliveryDate',type:'date'},
{name : 'deliveryAmount'},
{name : 'judgeReason'},
{name : 'remark'}
],
recordType : "object"
};
var colsOption = [
{id:'itemName',header:"<fmt:message key='PROJECTNAME'/>",width:60},//editor:{type:"text"}},
{id:'contractRatifyDate',header:"<fmt:message key='deliveryManage_po_to_sapstate_X.contractRatifyDate'/>",width:90},//editor:{type:"date"}},
{id:'poNo',header:"<fmt:message key='barcode_showDeliveryInfo.idxPoNO'/>",width:60},//editor:{type:"text"}},
{id:'rowItem',header:"<fmt:message key='barcode_showDeliveryInfo.rowItem'/>",width:50},//editor:{type:"text"}},
{id:'materialNo',header:"<fmt:message key='DP.MaterialNo'/>",width:60},//editor:{type:"text"}},
{id:'materialDepict',header:"<fmt:message key='barcode_showDeliveryNote.materielDepict'/>",width:60},//editor:{type:"text"}},
{id:'amount',header:"<fmt:message key='M11428'/>",width:60},//editor:{type:"text"}},
{id:'unit',header:"<fmt:message key='barcode_showDeliveryInfo.unit'/>",width:40},//editor:{type:"text"}},
{id:'waitReplayAmount',header:"<fmt:message key='DP.WaitReplyingAmount'/>",width:80},//editor:{type:"text"}},
{id:'requireDate',header:"<fmt:message key='deliveryManage_po_show.deliveryDate'/>",width:70},//editor:{type:"date"}},
{id:'deliveryType',header:"<fmt:message key='M11425'/>",width:60},//editor:{ type :"select" ,options : {'按订单日期交货': '按订单日期交货'}}}, //editor:{type:"text"}},
//{id:'shortAddress',header:"交货地址简写",width:80},//editor:{type:"text"}},
{id:'onWayAmount',header:"<fmt:message key='DP.OnWayAmount'/>",width:60},
{id:'unDeliveryAmount',header:"<fmt:message key='DP.UnDeliveryAmount'/>",width:70},
{id:'providerCode',header:"<fmt:message key='SupplierCode'/>",width:80},//editor:{type:"text"}},
{id:'providerName',header:"<fmt:message key='Supplier'/>",width:80},//editor:{type:"text"}},
{id:'buyerId',header:"<fmt:message key='PURCHASER'/>",width:50},//editor:{type:"text"}},
{id:'deliveryDate',header:"<fmt:message key='DELIVERYDATE'/>",width:70},//editor:{type:"date"}},
{id:'deliveryAmount',header:"<fmt:message key='M10223'/>",width:60},//editor:{type:"text"}},
{id:'judgeReason',header:"<fmt:message key='pingdingliyou'/>",width:80},
{id:'remark',header:"<fmt:message key='REMARK'/>",width:100}//,editor:{type:"text"}}
];
var gridOption={
id : "selectBuf",
width : "100%",
height : "400",
container : 'gridbox',
replaceContainer : true,
loadURL : "selectBuf.do?__METHOD=queryBuf",
dataset : dsOption,
columns : colsOption,
toolbarContent : "nav | goto | reload",
showIndexColumn : true
};
var mygrid = new Sigma.Grid(gridOption);
Sigma.Util.onLoad(Sigma.Grid.render(mygrid));
YAHOO.util.Event.on("searchBuf","click",function(e){
mygrid.cleanParameters();
mygrid.addParameters("poNo",YAHOO.util.Dom.get("poNo").value);
mygrid.addParameters("rowItem",YAHOO.util.Dom.get("rowItem").value);
YAHOO.util.Dom.get("poNo").value = "";
YAHOO.util.Dom.get("rowItem").value = "";
mygrid.reload(true,true);
});
});
[/code]
这个SPRING MVC的RESPONSEBODY注解,后台返回前台JAON数据时,报406错误,是因为你的URL请求的问题,如果是HTM的话,就不行的。你可以将URL改成url.json,即可。