Ajax Request parameters Complex object list, backend SPRINGMVC receive parameters

Source: Internet
Author: User

Also the same problem that wasted me a lot of time in this record

Problem Description:

Ajax request Backend, SPRINGMVC receive parameter, parameter is an object, property has list

Workaround:

Js:

function Save () {var gifts = [];  var rows = Detail.fngetnodes ();    for (var i = 0; i < rows.length; i++) {var gift = {};    var row = Detail.fngetdata (Rows[i]);    gift[' scode '] = Row.scode;    gift[' smarkertvalue '] = row.smarkertvalue; gift[' cpcount '] = count?    1:count;  Gifts.push (gift);  }  var params= {};//Parameter object params.templatename = $ (' #_tName '). Val ();  Params.templatecode = $ (' #templateCode '). Val ();  Params.infos = gifts; Send Ajax$.ajax ({URL: "/autoinsur/template/create.json", type: "POST", DataType: "JSON", Async:false, ContentType: ' Application/json;charset=utf-8 ', data:JSON.stringify (params), success:function (data) {if (Data.resultcode! = ' 0    ') {$.dopalert ("operation failed:" + data.resultmsg);  }}, Error:function () {$.dopalert ("The system is busy, please retry later"); } });}   Back-end controller code: @RequestMapping ("/template/create.json") @ResponseBodypublic Commonresult Create (@ Requestbody aigifttemplatequerydto dto) {return null;}   

Ajax Request parameters Complex object list, backend SPRINGMVC receive parameters

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.