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注解开发之集合类型參数绑定 数组绑定 需 ...
随机推荐
- 使用ANT将Android打包成Jar包
本文主要实现使用ANT,将Android项目打包成jar,为方便其他项目使用. ANT可以去官网下载(http://ant.apache.org/) 先介绍打包的步骤,打包脚本下方贴出 步骤: 1,将 ...
- 凌乱的桌子和与 Web 的设计理念说明
Python是一门脚本语言,因为能将其他各种编程语言写的模块粘接在一起,也被称作胶水语言.强大的包容性.强悍的功能和应用的广泛性使其受到越来越多的关注,想起一句老话:你若盛开,蝴蝶自来. 如果你感觉学 ...
- bzoj1734 [Usaco2005 feb]Aggressive cows 愤怒的牛 二分答案
[Usaco2005 feb]Aggressive cows 愤怒的牛 Time Limit: 5 Sec Memory Limit: 64 MBSubmit: 407 Solved: 325[S ...
- 转:sudo 的常见用法和参数选项
原文链接:http://wiki.ubuntu.org.cn/Sudo sudo,以其他用户身份执行一个命令. 用法 sudo -h | -K | -V sudo -v [-Akns] [-g gro ...
- AC日记——[SDOI2009]晨跑 bzoj 1877
1877: [SDOI2009]晨跑 Time Limit: 4 Sec Memory Limit: 64 MBSubmit: 2131 Solved: 1142[Submit][Status][ ...
- TCP/IP 协议栈
TCP(传输控制协议) 传输控制协议(Transmission Control Protocol,TCP)是一种面向连接的.可靠的.基于字节流的传输层通信协议,由IETF的RFC 793定义. 在因特 ...
- 记一次ORM的权衡和取舍
面对ORM的选型,有些人是根据自己熟悉程度来评判,有些人是根据他人的推荐来抉择,有些人觉得都差不多,随便了.当自己要真正做选择的时候,以上的这些依据都无法真正说服自己,因为不同的业务需求,不同的团队构 ...
- Systemtap examples, Network - 4 Monitoring TCP Packets
http://blog.163.com/digoal@126/blog/static/16387704020131014104256627/ 例子来自tcpdumplike.stp脚本, 当tcp ...
- Credit Memo和Debit Memo在AR以及AP中的概念比较
AR和AP中都有Credit Memo和Debit Memo的概念, 但是其含义和用法完全不一样,比较难懂,现在整理如下:AR中的CreditMemo和DebitMemo是和客户打交道:AR中的Cre ...
- How to Install a Language Pack
https://www.phpbb.com/kb/article/how-to-install-a-language-pack