SpringMvc參数的接受以及serializeArray的使用方法
需求:从页面提交一个table中的数据到后台,通经常使用于批量改动
把全部的数据到放到 input属性中,设置name定义成为对象的相关属性,使用Jquery的serializeArray这种方法封装成为对象,详细实现參考代码
$.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'>保存失败!
</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;">保存</a>
<!-- | <@ui.auth code='/product/abateStockProduct.do'><a class="abate" value="${partner[1].id}" style="cursor: hand;cursor: pointer;">失效</a></@ui.auth> -->
</td>
</tr>
<#assign index=index +1 />
</#list>
</#if>
@RequestMapping(value = "/radixAdjustAll.do", method = RequestMethod.POST)
@ResponseBody
public String radixAdjustAll(PartnerProduct partnerproduct) {
try {
service.updateRadixAdjustAll(partnerproduct.getPartnerProducts());
return "true";
} catch (Exception e) {
e.printStackTrace();
return "false";
}
}
SpringMvc參数的接受以及serializeArray的使用方法的更多相关文章
- springMVC參数传递
本文是本人在学习网络视屏springMVC的过程中的学习笔记. 为了更便于理解我决定从实际使用的角度解释. 我们在浏览器输入地址 http://localhost:8080/springMVC6/us ...
- ajax日期參数格式问题
今天遇到ajax传输日期參数后台无法识别的问题,错误异常例如以下. 从异常中能够看出传输到后台的日期数据格式为Thu Aug 13 2015 19:45:20 GMT+0800 (中国标准时间),这样 ...
- Hadoop Ls命令添加显示条数限制參数
前言 在hadoop的FsShell命令中,预计非常多人比較经常使用的就是hadoop fs -ls,-lsr,-cat等等这种与Linux系统中差点儿一致的文件系统相关的命令.可是细致想想,这里还是 ...
- C# 多线程參数传递
1.通过实体类来传递(能够传递多个參数与获取返回值),demo例如以下: 须要在线程中调用的函数: namespace ThreadParameterDemo { public class Funct ...
- 一起talk C栗子吧(第一百二十七回:C语言实例--查看main函数的參数)
各位看官们,大家好,上一回中咱们说的是static关键字的样例,这一回咱们说的样例是:查看main函数的參数.闲话休提,言归正转.让我们一起talk C栗子吧! 看官们.我们在第五十七回中介绍过mai ...
- JVM、垃圾回收、内存调优、常见參数
一.什么是JVM JVM是Java Virtual Machine(Java虚拟机)的缩写.JVM是一种用于计算设备的规范.它是一个虚构出来的计算机,是通过在实际的计算机上仿真模拟各种计算机功能来实现 ...
- 【Jquery】jQuery获取URL參数的两种方法
jQuery获取URL參数的关键是获取到URL,然后对URL进行过滤处理,取出參数. location.href是取得URL.location.search是取得URL"?"之后的 ...
- [javase学习笔记]-6.5 类类型參数与匿名对象
这一节我们来说说类类型參数和匿名对象. 我们继续用之前的小汽车类吧 class Car { int num;//这是轮胎数属性 String color;//这是颜色属性 String brand;/ ...
- springmvc学习笔记(13)-springmvc注解开发之集合类型參数绑定
springmvc学习笔记(13)-springmvc注解开发之集合类型參数绑定 标签: springmvc springmvc学习笔记13-springmvc注解开发之集合类型參数绑定 数组绑定 需 ...
随机推荐
- iOS学习笔记19-地图(一)定位CoreLocation
一.定位介绍 现在很多社交.电商.团购应用都引入了地图和定位功能,似乎地图功能不再是地图应用和导航应用所特有的.的确,有了地图和定位功能确实让我们的生活更加丰富多彩,极大的改变了我们的生活方式.要实现 ...
- 将list分成等数量
import java.util.ArrayList; import java.util.List; public class CollectionGroupUtil { public static ...
- bzoj 5055: 膜法师 树状数组+离散
先枚举每一个数,看它前面有几个比它小,算一下和为sum1,后面有几个比它大,算一下和为sum2,对答案的贡献为A[i]*sum1*sum2. 离散化后,树状数组就可以了. 就是倒着一边,顺着一边,统计 ...
- 简单题(bzoj 1683)
Description 你有一个N*N的棋盘,每个格子内有一个整数,初始时的时候全部为0,现在需要维护两种操作: 命令 参数限制 内容 1 x y A 1<=x,y<=N,A是正整数 将格 ...
- jsp、Html页面注释的种类
<!-- 这里面的注释在查看页面源代码时,依旧可以看到,另外页面加载时这里面注释的内容仍旧会编译 --> <%-- JSP中的注释,这里面的内容在查看页面源代码时,看不到这里面注释书 ...
- SELinux 服务检查与关闭
查看SELinux状态: 1./usr/sbin/sestatus -v ##如果SELinux status参数为enabled即为开启状态 SELinux status: ...
- Java中jshell脚本
1.当所编写的代码量少时,倘若要按照步骤会显得繁琐,可直接用JDk当中的jshell,进入cmd,输入jshell,即进入jshell脚本交互模式.省去繁琐的定义类,main方法,可直接输出Syste ...
- Oracle释放高水位线
/*****************************************************************原因:由于原导出数据库没有整理表空间其中主要包括两方面,一是用户产生 ...
- 转: 在CentOS 6.X 上面安装 Python 2.7.X
转:https://ruiaylin.github.io/2014/12/12/python%20update/ 评注: yum -y update //这个更新太坑了,1120更新包...想死的心都 ...
- docker下用keepalived+Haproxy实现高可用负载均衡集群
启动keepalived后宿主机无法ping通用keepalived,报错: [root@localhost ~]# ping 172.18.0.15 PING () bytes of data. F ...