求解。。。。。。。。。。。。。。。
23 回复
加了适配也不行啊
@AdaptBy(type = JsonAdaptor.class)
public Object assignRfidDo(@Param("toolsId")String toolsId,@Param("list")List<Map<String,String>> listStr,HttpServletRequest req){
System.out.println( listStr);
}
后台listStr打印出来是:[[{},{}]]
前端的list打印出来是:
(2) [Map(4), Map(4)]
0: Map(4) {"Store0" => "09f9a228d4144ca88dfad836bc26b30f", "Cab0" => "ec735e5f8d854d07818161c617990828", "Space0" => "bebd844438db479581887cdf8f696082", "Number0" => "1"}
1: Map(4) {"Store1" => "953047271cd24a9db42c2d927444e486", "Cab1" => "8fabf25af731453d8966f591298895f3", "Space1" => "4e1dd2bc7425440b94f3795a78474fcc", "Number1" => "1"}
length: 2
不用JSON.stringify(),直接传list也不行
$.post("${base}/plat/cab/assignDo", {
list:JSON.stringify(list),
toolsId: "${obj.id}"
}, function (data) {
if (data.code == 0) {
Toast.success(data.msg);
datatable.ajax.reload();
datatable_rfids.ajax.reload();
} else {
Toast.error(data.msg);
}
$('#assignToolsPanel').modal('hide');
}, "json");
要整个body都是json字符串
$.post("${base}/plat/cab/assignDo", JSON.stringify({list:list,toolsId: "${obj.id}"}), function (data) {
if (data.code == 0) {
Toast.success(data.msg);
datatable.ajax.reload();
datatable_rfids.ajax.reload();
} else {
Toast.error(data.msg);
}
$('#assignToolsPanel').modal('hide');
}, "json");
var list = new Array();
for (var a = 0; a < window.rows; a++) {
var map = new Map();
map.set("Store"+a,$("#Store"+a).find("option:selected").val());
map.set("Cab"+a,$("#Cab"+a).find("option:selected").val());
map.set("Space"+a,$("#Space"+a).find("option:selected").val());
map.set("Number"+a,$("#Number"+a).val());
list.push(map);
}
var map = {} 的话。。。页面直接报错了
Uncaught TypeError: map.set is not a function
at save (eval at <anonymous> (jquery-1.11.1.min.js:2), <anonymous>:102:17)
at HTMLAnchorElement.onclick (tools:1)
十分感谢!!!用这个map就好了,还问一下就是后端接收的list里又套了一个list,这是怎么回事?
[[{"Store0":"09f9a228d4144ca88dfad836bc26b30f","Cab0":"ec735e5f8d854d07818161c617990828","Space0":"bebd844438db479581887cdf8f696082","Number0":"1"},{"Store1":"09f9a228d4144ca88dfad836bc26b30f","Cab1":"ec735e5f8d854d07818161c617990828","Space1":"bebd844438db479581887cdf8f696082","Number1":"1"}]]
前端打印则是正常的
[{"Store0":"09f9a228d4144ca88dfad836bc26b30f","Cab0":"ec735e5f8d854d07818161c617990828","Space0":"bebd844438db479581887cdf8f696082","Number0":"1"},{"Store1":"09f9a228d4144ca88dfad836bc26b30f","Cab1":"ec735e5f8d854d07818161c617990828","Space1":"bebd844438db479581887cdf8f696082","Number1":"1"}]
添加回复
请先登陆