Send array as value of JS object so you end up as {json:[1,2,3,4]}
.
var json=[1,2,3,4];
$.ajax({
url:"myUrl",
type:"POST",
dataType:'json',
data: {json:json},
success:function(data){
// codes....
},
});
In servlet, you need to suffix the request parameter name with []
.
String[] myJsonData = request.getParameterValues("json[]");
jQuery appends them in order to be friendly towards weak typed languages like PHP.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…