my ajax function called as
$.ajax({
url:'${pageContext.request.contextPath}'+'/admin/sendMsg',
method:'POST',
traditional: true,
data:{
driverList: JSON.stringify(drivers),
constList: JSON.stringify(constIds),
content: content
},
success: function(data) {
if (data == "FAIL") {
alert("File not found!");
}
},
error: function(request, status, error) {
alert("The request failed: " + request.responseText);
}
});
Where variable "drivers" and "constIds" are array object, output by browser console like
["0", "31", "30"]
0: "0"
1: "31"
2: "30"
length: 3__proto__: Array(0)
My controller:
@ResponseBody
@RequestMapping(value = "/sendMsg", method = RequestMethod.POST)
public void sendMsg(HttpSession session,
@RequestParam(value = "driverList")String[] driverList,
@RequestParam(value = "constList")String[] constList, @RequestParam(value = "content")String content)
{
for (String data : driverList) {
System.out.println("Your Data =>" + data);
}
System.out.println(constList);
}
But the output is
Your Data =>["0"
Your Data =>"31"
Your Data =>"30"]
So how can I get rid of those brackets, then I can parse the string to Integer.