前端JS代碼:
  var conditons = [];  var test1 = new Object();  test1.name="1";  test1.id="2";  var test2 = new Object();  test2.name="1";  test2.id="2";  conditons.push(test1);  conditons.push(test2);  $(function(){    $.ajax({      async:"false",      type:'post',      url:'鏈接',       data:{name:"123",conditions:JSON.stringify(conditons)},      dataType : 'json',       success:function(data){        console.log(data);      },      error: function (XMLHttpRequest, textStatus, errorThrown){        alert("error");      }    });  });重點注意:將對象數組轉為JSON形式的字符串:JSON.stringify
后端獲取:
String conditions = request.getParameter("conditions");JSONArray conditionList = JSONArray.fromObject(conditions);以上就是小編為大家帶來的JS傳遞對象數組為參數給后端,后端獲取的實例代碼全部內容了,希望大家多多支持武林網~
新聞熱點
疑難解答