如果中checkbox选中多条记录向后台传值,js实现如下

var orderIds=[];
                var userCodes=[];
                $("input[name='cBox']:checked").each(function(){
//选中的checkbox记录,循环取出每条记录中orderId和userCode
                    var orderId=$(this).val();
                    var userCode=$(this).attr("userCode");
                    orderIds.push(orderId);
                    userCodes.push(userCode);
                });

                    $.ajax({
                        url:"batch.do",
                        data:"orderIds="+orderIds.join(",")+"&userCodes="+userCodes.join(","),
                        type:"post",
                        dataType:"text",
                        success: function(result){

                            alert(result);
                        }
                    });
                }

java后台接收数据

@RequestMapping(value="batch.do")
public String batch(HttpServletResponse response,HttpServletRequest request,HttpSession session){
        CustomerDBContextHolder.setDataSourceType(DataSourceInstances.WRITE_DATASOURCE);
        String orderIds = request.getParameter("orderIds");
        String[] orderId = orderIds.split(",");
        String userCodes = request.getParameter("userCodes");
        String[] userCode = userCodes.split(",");

html页面


                        row-evenrow-odd">