欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

springMvc 前端用json的方式向后臺(tái)傳遞對(duì)象數(shù)組方法

 更新時(shí)間:2018年08月07日 08:37:56   作者:ITBOY_ITBOX  
今天小編就為大家分享一篇springMvc 前端用json的方式向后臺(tái)傳遞對(duì)象數(shù)組方法,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過來看看吧

如下所示:

JSP
var vipFee= new Array;
//遍歷選中的對(duì)象

$("#feeList :checkbox:checked").each(function(i){
 vipFee.push({"enterpriseSeq":$(this).attr("enterpriseSeq"),"merchNo":$(this).val(),"serviceFee":$(this).attr("fqbFee")});
  });
//進(jìn)行異步
$.ajax({ 
 type:"POST", 
 url: "addVipFeeList", 
 async:false,
 dataType:"json", 
 contentType:"application/json", // 指定這個(gè)協(xié)議很重要 
 data:JSON.stringify(vipFee), 
 success:function(data){ 
   //判斷是否是成功的返回的
  if(data.success===true){
   $("#feeList :checkbox:checked").each(function(i){
   var FQBFee = parseFloat($(this).parent().siblings("td").find("input[name='fqbFee']").val());
   $(this).parent().siblings("td").find("input").attr("readonly","readonly");
   $(this).parent().siblings("td").find("input[name='fqbFee']").val(FQBFee.toFixed(3));
   //將“取消定價(jià)”,進(jìn)行顯示
   $(this).parent().siblings("td").find("a[id='cancelA']").show();
   //將“確定定價(jià)”進(jìn)行隱藏
   $(this).parent().siblings("td").find("a[id='relateA']").hide();
   //取消掉選中的狀態(tài)
   $(this).prop("checked", false);
   });
   }
     } 
   }); 

Controller
 @RequestMapping(value = Constants.ADMIN + "/addVipFeeList",method=RequestMethod.POST)
 @ResponseBody
 public Map<String,Object> addVipFeeList(@RequestBody List<VipFee> vipFee){
  Map<String,Object> map=new HashMap<String,Object>();
  try {
   //判斷對(duì)象是否為空
   if (vipFee!=null&&vipFee.size()>0) {
    //進(jìn)行遍歷并賦值
    for (VipFee v:vipFee) {
     v.setReplacePrdId(Constants.PRODUCT_TYPE_FQB);
    }
   }
   //進(jìn)行添加
   vipFeeService.addVipFeeList(vipFee);
   map.put("success", true);
  } catch (CoreException e) {
   map.put("success", false);
   log.error(e.getCode(),e);
   map.put("errorMsg", e.getCode());
  }
  return map;
 }

以上這篇springMvc 前端用json的方式向后臺(tái)傳遞對(duì)象數(shù)組方法就是小編分享給大家的全部內(nèi)容了,希望能給大家一個(gè)參考,也希望大家多多支持腳本之家。

相關(guān)文章

最新評(píng)論