java前台往后台传递list,后台如何接受
2017-01-18 09:55
447 查看
$("#confirmSample").bind("click", function () { var userCodeArr = new Array(); $(".checkbox").each(function(){ if ($(this).attr("checked")) { userCodeArr.push($(this).val()); } }); if (userCodeArr.length == 0) { alert("请至少选择一条记录。"); return; } var truthBeTold = window.confirm("确认抽样?"); if (truthBeTold) { $("#confirmSample").val("确认ing"); $.ajax({ type: "POST", url: "${dynamicURL}/monthlyAvgTravelSample/confirmRandomSampleList", data: {"userCodeArr":userCodeArr,"startdate":$("#start").val(),"enddate":$("#end").val()}, dataType: "json", //contentType: "application/json;charset=utf-8", success: function(data){ if (data.result == "success") { alert("抽样确认成功"); var month = new Date().getMonth() + 1; if (month < 10) { month = "0"+month; } var strDate = new Date().getFullYear() + "-" + month + "-" + new Date().getDate(); $(".checkbox").each(function(){ if ($(this).attr("checked")) { var cd = $(this).parent().siblings("#chosen").text().split("-"); if (cd.length != 3){ $(this).parent().siblings("#chosen").html(strDate); } } }); } else { alert("抽样确认失败"); } $("#confirmSample").val("抽样确认"); } }); } });
userCodeArr是一个数组,后台如何接受呢
@RequestMapping(value = "/confirmRandomSampleList")
@ResponseBody
public JSONObject confirmRandomSampleList (@RequestParam(required = false, value = "userCodeArr[]") List<String> userCodeArr, @RequestParam(required = false, value = "startdate") String startdate, @RequestParam(required = false, value = "enddate") String enddate) {
Map map = new HashMap();
map.put("result","success");
return JSONObject.fromObject(map);
}
相关文章推荐
- java代码中后台向前台传递list或map集合案例
- java后台接受web前台传递的数组参数
- easyui datetimebox处理【前台传递到后台是string类型,但是后台定义的是java.util.date,如何自动转换数据类型】
- MVC后台创建Json(List)前台接受并循环读取实例
- java后台向前台传一个list,前台接收报错
- MVC后台返回List<int>ViewData, 前台接受
- javaScript如何处理从java后台返回的list
- MVC中前台如何向后台传递数据------$.get(),$post(),$ajax(),$.getJSON()总结
- MVC后台创建Json(List),前台接受并循环读取
- java把List从后台传到前台jsp页面
- Java 前台后台数据传递、中文乱码解决方法
- 前台传过来来好几个对象,后台同时接受这几个相同的javabean: 实践总结
- 如何在前台脚本通过json传递数据到后台(使用微软自带的ajax)
- Spring MVC前台向后台传递一个List
- 前台如何将多个json对象传入java后台[修正]
- Java 后台向前台传递中文乱码
- 如何在前台脚本通过json传递数据到后台(使用微软自带的ajax)
- 如何在前台脚本通过json传递数据到后台(使用微软自带的ajax)
- 使用JAVA引用类型传递后台信息给前台的进度条
- EF5+MVC4系列(7) 后台SelectListItem传值给前台显示Select下拉框;后台Action接收浏览器传值的4种方式; 后台Action向前台View视图传递数据的四种方式(ViewDate,TempDate,ViewBag,Model (实际是ViewDate.Model传值))