我已使用以下代码将所有表格转换为json格式:
var table2 = $('#yTable').tableToJSON();
alert(JSON.stringify(table2));
如何将这三个json数组发送到弹簧控制器?在spring控制器中,我想将这些json对象数组作为单独的参数:
[
{"Label":"A","Dimension":"0"},
{"Label":"B","Dimension":"10"},
{"Label":"C","Dimension":"20"},
{"Label":"D","Dimension":"30"},
{"Label":"E","Dimension":"40"}
]
[
{"Label":"1","Dimension":"0"},
{"Label":"2","Dimension":"10"},
{"Label":"3","Dimension":"20"},
{"Label":"4","Dimension":"30"},
{"Label":"5","Dimension":"40"}]
[
{"Label":"Floor1","Dimension":"0"},
{"Label":"Floor2","Dimension":"10"},
{"Label":"Floor3","Dimension":"20"},
{"Label":"Floor4","Dimension":"30"},
{"Label":"Floor5","Dimension":"40"}
]
ajax电话
$.ajax({
type: "POST",
contentType : 'application/json; charset=utf-8',
dataType : 'json',
url: "/bimspring/gridData",
data: JSON.stringify(postData),
success : function(response) {
// do something ...
},
error : function(e) {
alert('Error: ' + e);
}
});
控制器
@RequestMapping(value = "/gridData", method = RequestMethod.POST)
public @ResponseBody String getSearchUserProfiles(@RequestBody Search[] list) {
return null;
}