本文由黑壳博客原创
壳叔搞笑时间
内容
数据主体 + 集合数据 同时传入后台,下面直接上干货
示例代码
JavaScript 代码
//提交
function submitOrder() {
var doingOrderWrapper = {};
var objHeader = $("#orderForm").serializeObject();
doingOrderWrapper.doingOrderBean = objHeader;
doingOrderWrapper.doingOrder1Beans = addProductList;
$.ajax({
type: "POST",
dataType: "json",
async: true,
contentType: "application/json; charset=utf-8",
url: "order/submitOrder",
data: JSON.stringify(doingOrderWrapper),
success: function (ajaxobj) {
var jsonStr=eval(ajaxobj);
console.log(jsonStr.msg);
alert(jsonStr.msg);
},
error: function (req) {
alert(req)
console.log(req);
}
});
}
Java Bean 类
@JsonIgnoreProperties(ignoreUnknown = true)
public class DoingOrderWrapper {
private DoingOrderBean doingOrderBean;
private List<DoingOrder1Bean> doingOrder1Beans;
public DoingOrderBean getDoingOrderBean() {
return doingOrderBean;
}
public void setDoingOrderBean(DoingOrderBean doingOrderBean) {
this.doingOrderBean = doingOrderBean;
}
public List<DoingOrder1Bean> getDoingOrder1Beans() {
return doingOrder1Beans;
}
public void setDoingOrder1Beans(List<DoingOrder1Bean> doingOrder1Beans) {
this.doingOrder1Beans = doingOrder1Beans;
}
}
Controller 控制层
@Controller
@RequestMapping(value = "/order")
public class OrderAction extends BaseAction {
/**
* 生成产品订单 * * @return
*/ @RequestMapping(value = "/submitOrder")
@ResponseBody public StatusBean submitOrder(@RequestBody DoingOrderWrapper doingOrderWrapper) {
//doingOrderWrapper 接收前台批量传值
}
}
About
程序员太辛苦了
请善待你们身边的每一位程序员~
欢迎在评论写下你的程序员趣事,程序员不是一个死板的职业~~
以上内容,均来自互联网~
欢迎扫描二维码加入我们的小组织 ,大家都叫壳叔,期待你的到来。
Group
黑壳网交流群 Q群:200408242
交流群 来者便是客
黑壳博客 blog.bhusk.comE-mail:keshu@bhusk.com
本文由 黑壳博客的壳叔 创作或转载,采用 知识共享署名 3.0 中国大陆许可协议 进行许可。
可自由转载、引用,但需署名作者且注明文章