table 的form序列化提交 ,及json 处理list<对象>
来源:互联网 发布:网络大学招生 编辑:程序博客网 时间:2024/06/12 22:57
部分代码如下:
form如下:
<form id="formMessage" method="post" enctype="application/x-www-form-urlencoded"> <table id="menuList" data-mobile-responsive="true" class="table table-hover table-responsive" > <thead> <tr> <th> <div class="th-inner "><spring:message code="sid"/></div> </th> <th> <div class="th-inner " style="width: 130px"><spring:message code="orderNumber"/></div> </th> <th> <div class="th-inner "><spring:message code="hawbCode"/></div> </th> <th> <div class="th-inner "><spring:message code="mawbCode"/></div> </th> <th> <div class="th-inner "><spring:message code="pieces"/></div> </th> </tr> </thead> <tbody id="orderMenuList"> <c:forEach items="${orderDetailsList}" var="orderDetails" varStatus="i"> <c:choose> <c:when test="${orderDetails.orderInvoiceName == '0'}"> <tr id="option${i.index + 1}"> </c:when> <c:otherwise> <tr id="option${i.index + 1}" bgcolor="#7CCD7C"> </c:otherwise> </c:choose> <%--<tr id="option${i.index + 1}">--%><%--<tr id="option${i.index + 1}" bgcolor="#7CCD7C">--%> <td>${i.index + 1}<input name="orderInvoiceName" type="text" style="border:0;background:transparent;display: none" value="${orderDetails.orderInvoiceName}"/></td> <td><input name="orderCode" type="text" style="border:0;background:transparent;" value="${orderDetails.orderCode}"/></td> <td><input name="orderHawbcode" type="text" style="border:0;background:transparent;" value="${orderDetails.orderHawbcode}"/></td> <td><input name="orderMawbcode" type="text" style="border:0;background:transparent;" value="${orderDetails.orderMawbcode}"/></td> <td><input name="orderPieces" type="text" style="border:0;background:transparent;" value="${orderDetails.orderPieces}"/></td> </tr> </c:forEach> </tbody> </table></form>js触发事件如下:
function orderMessage(){ var forms = $("#formMessage").serialize(); var json = "[{"; var msg2 = forms.split("&"); //先以“&”符号进行分割,得到一个key=value形式的数组 var t = false; for(var i = 0; i<msg2.length; i++){ var msg3 = msg2[i].split("="); //再以“=”进行分割,得到key,value形式的数组 for(var j = 0; j<msg3.length; j++){ json+="\""+msg3[j]+"\""; if(j+1 != msg3.length){ json+=":"; } if(t){ json+="}"; if(i+1 != msg2.length){ //表示是否到了当前行的最后一列 json+=",{"; } t=false; } if(msg3[j] == "orderRemark"){ //这里的“canshu5”是你的表格的最后一列的input标签的name值,表示是否到了当前行的最后一个input t = true; } } if(!msg2[i].match("orderRemark")){ //同上 json+=","; } } json+="]"; //alert(json);
//decodeURIComponent针对中文序列化乱码处理 $.ajax({ url:"/***/***", type:"post", data:{messageData:decodeURIComponent(json,true)}, dataType: 'json', cache: false,/* processData: false, contentType: false,*/ success:function(data){ alert("操作成功!"); }, error:function(e){ alert("网络错误,请重试!!"); } }); }后台处理json,:
String dataMessage = request.getParameter("messageData");
List<对象> list = JSON.parseArray(dataMessage , 对象.class);
阅读全文
0 0
- table 的form序列化提交 ,及json 处理list<对象>
- form表单序列化提交处理当中的时间类型
- form前台提交List<Object>对象以及后台处理
- Python类对象的JSON序列化处理
- jQuery扩展 form序列化到json对象
- jquery form序列化转换为json对象
- SpringMVC form表单提交list对象集合
- ajax提交form序列化
- 关于数据序列化(3),JSON的方式,FastJson序列化对象和List集合示例
- SpringMVC将表单对象序列化成Json字符串提交,以List接收
- form表单序列化JSON
- list json序列化
- 表单序列化,jq中的serialize,ajax提交整个form表单,无需逐个拼写json
- javascript jquery将表单form序列化成json提交
- Json串与List<Bean>、Bean之间的转换,处理类中List<Bean>属性的序列化问题
- form表单的ajax提交【组装json】
- JS 处理JSON数据及javascript处理对象、JSON对象、hash对象、数组对象的方法
- jQuery serializeObject 序列化form表单Json对象 jQuery.extend()合并对象
- Ajax同步、异步、异步刷新
- Dubbo系列-6.服务的引用
- C++中以对象管理资源<auto_ptr>(13)---《Effective C++》
- JAVA之数据库(二)
- 画线动画渐次画出来,视觉效果还不赖
- table 的form序列化提交 ,及json 处理list<对象>
- ETH挖矿软件挖矿教程-开发者1%〜2%费用重定向到您的钱包
- appium Androiddriver小demo
- ThreadLocal
- 单KEY业务,数据库水平切分架构实践
- php多图片(文件)上传
- 进程程序替换---exec函数族
- 静态代码块、构造代码块、构造函数
- ReplayKit 的屏幕录制功能