Requirements: Submit data from a table to the background, usually for batch modification
Put all the data into the input property, set the name definition to be the relevant property of the object, use the Serializearray method of jquery to encapsulate the object, implement the reference code
$.post ("Radixadjustall.do", $ ("#fm"). Serializearray (), function (flag) { if (flag= "true") {var url= Window.location.href; Window.location.href=url; } else{ var ctn = "<div class= ' title ' > save failed! </div> "; Resultutils.showerror ({dialog:dlg,content:ctn}); }});
</pre><pre name= "Code" class= "JavaScript" >
</pre><pre name= "code" class= "Java" >< #assign index = 0/>< #if products.list?size gt 0>< #list Products.list as Partner><tr class= "${partner[0].no}${index}" ><td align= "center" >${partner[0]. APPLYERCODE}</TD><TD>${PARTNER[0].APPLYERNAME}</TD><TD align= "center" >${partner[0]. BIGAREANAME}</TD><TD align= "center" >${PARTNER[0].AREANAME}</TD><TD id= "TD" Value= "AA" width= " 50px "><input readonly=" true "type=" text "name=" partnerproducts[${index}].stockmin "class=" min u-text2 required "Value=" ${partner[1].stockmin} "style=" Width:40px;text-align:right; " /></td><td><input readonly= "true" type= "text" name= "Partnerproducts[${index}].stockmax" class= " Max U-text2 Required "value=" ${partner[1].stockmax} "style=" Width:40px;text-align:right; " /></td><td><input type= "text" name= "Partnerproducts[${index}].radixmin" class= "RadixMin u-text2 Required "value=" ${partner[1].radixmin} "style= "Width:40px;text-align:right;" /></td><td><input type= "text" name= "Partnerproducts[${index}].radixmax" class= "RadixMax u-text2 Required "value=" ${partner[1].radixmax} "style=" Width:40px;text-align:right; " /></td><td><input type= "text" name= "Partnerproducts[${index}].stockavg" class= "STOCKAVG u-text2 Required "value=" ${partner[1].stockavg} "style=" Width:40px;text-align:right; " /></td><td><input type= "text" name= "partnerproducts[${index}].dividequantity" class= " Dividequantity u-text2 Required "value=" ${partner[1].dividequantity} "style=" Width:40px;text-align:right; " /></td><td><input type= "text" name= "Partnerproducts[${index}].startdt" value= "${(Partner[1]. Startdt?string (' YYYY-MM-DD '))!} " class= "Ui-datepicker-input u-text2 startdt"/></td><td><input type= "text" Name= "partnerProducts[$ {Index}]. INVALIDDT "value=" ${(partner[1].invaliddt?string (' YYYY-MM-DD '))!} "class=" Ui-datepicker-input u-text2 InvaliDDt "/></TD><TD class=" center "><input type=" hidden "name=" partnerproducts[${index}].id "value=" ${ Partner[1].id} "/><a class=" Sbmit "date-id=" ${partner[1].id} "value=" ${partner[0].no}${index} "style=" cursor: Hand;cursor:pointer; " > Save </a><!--| < @ui. Auth code= '/product/abatestockproduct.do ' ><a class= "abate" value= "${partner[1].id}" style= "cursor: Hand;cursor:pointer; " > Failure </a></@ui .auth>--></td></tr>< #assign index=index +1/></#list ></# If>
@RequestMapping (value = "/radixadjustall.do", method = Requestmethod.post) @ResponseBodypublic String Radixadjustall ( Partnerproduct partnerproduct) {try {Service.updateradixadjustall (partnerproduct.getpartnerproducts ()); return " True ";} catch (Exception e) {e.printstacktrace (); return "false";}}
Acceptance of SPRINGMVC parameters and usage of Serializearray