Front-end JS code:
var conditionons = []; var test1 = new Object(); test1.name="1"; test1.id="2"; var test2 = new Object(); test2.name="1"; test2.id="2"; conditionons.push(test1); conditionons.push(test2); $(function(){ $.ajax({ async:"false", type:'post', url:'link', data:{name:"123", conditions:JSON.stringify(conditons)}, dataType : 'json', success:function(data){ console.log(data); }, error: function (XMLHttpRequest, textStatus, errorThrown){ alert("error"); } }); });Key points: Convert an array of objects to strings in JSON form: JSON.stringify
Backend fetch:
String conditions = request.getParameter("conditions");JSONArray conditionList = JSONArray.fromObject(conditions);The above is the entire content of the example code obtained by the JS passing object array as parameters for the backend and the backend is obtained. I hope everyone supports Wulin.com more~