springMvc 前端用json的方式向后台传递对象数组方法
网络编程 2021-07-04 16:46www.168986.cn编程入门
今天长沙网络推广就为大家分享一篇springMvc 前端用json的方式向后台传递对象数组方法,具有很好的参考价值,希望对大家有所帮助。一起跟随长沙网络推广过来看看吧
如下所示:
JSP var Fee= new Array; //遍历选中的对象 $("#feeList :checkbox:checked").each(function(i){ Fee.push({"enterpriseSeq":$(this).attr("enterpriseSeq"),"merchNo":$(this).val(),"serviceFee":$(this).attr("fqbFee")}); }); //进行异步 $.ajax({ type:"POST", url: "addVipFeeList", async:false, dataType:"json", contentType:"application/json", // 指定这个协议很重要 data:JSON.stringify(Fee), suess:function(data){ //判断是否是成功的返回的 if(data.suess===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)); //将“取消定价”,进行显示 $(this).parent().siblings("td").find("a[id='cancelA']").show(); //将“确定定价”进行隐藏 $(this).parent().siblings("td").find("a[id='relateA']").hide(); //取消掉选中的状态 $(this).prop("checked", false); }); } } }); Controller @RequestMapping(value = Constants.ADMIN + "/addVipFeeList",method=RequestMethod.POST) @ResponseBody public Map<String,Object> addVipFeeList(@RequestBody List<VipFee> Fee){ Map<String,Object> map=new HashMap<String,Object>(); try { //判断对象是否为空 if (Fee!=null&&Fee.size()>0) { //进行遍历并赋值 for (VipFee v:Fee) { v.setReplacePrdId(Constants.PRODUCT_TYPE_FQB); } } //进行添加 FeeService.addVipFeeList(Fee); map.put("suess", true); } catch (CoreException e) { map.put("suess", false); log.error(e.getCode(),e); map.put("errorMsg", e.getCode()); } return map; }
以上这篇springMvc 前端用json的方式向后台传递对象数组方法就是长沙网络推广分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持狼蚁SEO。
编程语言
- 机械手焊接机器人编程 机械手焊接设备编程
- vb数据库编程实例,vb做数据库
- tiobe世界编程语言排行榜,全球编程语言排行
- 成都java编程培训 成都it编程培训中心
- 编程基础培训,编程基础知识培训
- flash游戏编程基础教程,flash游戏开发教程
- 不会英语能学编程吗 不会英语可以学程序员吗
- 爱心代码编程C语言 爱心代码编程c语言公式
- c语言编程学习入门 c语言编程快速入门
- 西门子plc编程培训 西门子plc编程培训班
- 哪里可以学编程 台州哪里可以学编程
- 少儿编程哪个好 少儿编程哪个品牌好
- 编程是什么意思,图形编程是什么意思
- c语言编程软件下载,c语言编程软件在哪下载
- java编程软件下载,java编程下载手机版
- ug编程培训学校,ug编程培训教程