在我的数组中:
{
"keys": [
"a",
"b",
"c",
"d",
"e",
"f"
],
"data": [
[
"hh",
"hh",
"jk",
"ggh",
"hvh",
null
],
[
"dd",
"gg",
null,
"nn",
"rr",
"jj"
]
]
}
我想在控制器类中传递上面的数组数据:
$.ajax({
url: '/MobitelProgressTool/wifi_mane',
data: JSON.stringify(list),
type: 'POST', //<== not 'GET',
contentType: "application/json; charset=utf-8",
dataType: 'json',
error: function () {
console.log("error");
},
success: function (arr) {
console.log(arr.testArray);
var testArray = arr.testArray;
$.each(function (i, e) {
document.writeln(e);
});
}
});
控制器类是......
RequestMapping(value = {"/wifi_mane"}, method = RequestMethod.POST)
@ResponseBody// <== this annotation will bind Arr class and convert to json response.
public Arr addAnotherAppointment(HttpServletRequest request, HttpServletResponse response, @RequestBody Arr arr, Model model, BindingResult errors) {
System.out.println("^^^^^^^^^^" + arr.getTestArray());
return arr;
}
我的数组类是:
public class Arr {
private List<String> testArray;
/**
* @return the testArray
*/
public List<String> getTestArray() {
return testArray;
}
/**
* @param testArray the testArray to set
*/
public void setTestArray(List<String> testArray) {
this.testArray = testArray;
}
但是我无法传递数组数据?
答案 0 :(得分:0)
尝试这个,我认为这应该有效:
public class Arr {
private List<String> keys;
private List<List<String>> data;
//... getters and setters
}