ajax、form表单提交列表请求
使用以下方法是不可行的,会报错
controller is neither an array nor a List nor a Map
var list= []; list.push(obj1); list.push(obj2; $.ajax({ "url" : url, "type" : "POST", "dataType" : "json", "data" : {labels:list}, "success" : function(msgjsonobj) { }, "error" : function(msgjsonobj) { } });
应该使用以下的方法
var data; data['labels[0].id']=1; data['labels[0].name']=1; data['labels[1].id']=1; data['labels[1].name']=1; $.ajax({ "url" : url, "type" : "POST", "dataType" : "json", "data" : data, "success" : function(msgjsonobj) { }, "error" : function(msgjsonobj) { } });
form表单请求则是
<input type="hidden" name="labels[0].id" value="1"/> <input type="hidden" name="labels[0].name" value="1"/> <input type="hidden" name="labels[1].id" value="1"/> <input type="hidden" name="labels[1].name" value="1"/>