ajax参数传递是list集合传到后端

前端jquery:

function SalaryBills(){
	var datalistBill = new Array();
	$(".companyC").each(function(e){
		var data;
		var addIdStr="";
		var companyId;
		var monthDate;
		var historySalary;
		var remarks;
		var len = $(".companyC").eq(e).find(".addNameCB:checked").length;
		$(".companyC").eq(e).find(".addNameCB:checked").each(function(i){
			if(i==len-1){
				addIdStr += $(this).val();
				  
    		}else{
    			addIdStr += $(this).val()+",";
    		}
		});
		companyId = $(".companyC").eq(e).find(".companyIdC").val();
		monthDate = $(".companyC").eq(e).find(".monthDateC").text();
		historySalary = $(".companyC").eq(e).find(".historySalary").val();
		remarks = historySalary;
		if((addIdStr!="" ||addIdStr!=undefined)&&(monthDate!="" ||monthDate!=undefined)&&(companyId!="" ||companyId!=undefined)){
			data = {};
    		var data1 = new Object();
    		data1.companyId = companyId;
    		data1.monthDate = monthDate;
        	data.companyLaborSalary= data1;
        	data.addIdStr = addIdStr;
        	data.historySalary = historySalary;
        	data.remarks = remarks;
        	datalistBill.push(data);
		}
	});
		$.ajax({
	        type: "POST",
	        url: contextPath + '/home/salary!withholdBillFormSession.htm',
	        data: {'datalistBill':JSON.stringify(datalistBill)},
	        dataType: 'json',
	        async: false,
	        success: function(){
	        	window.open(contextPath + "/home/salary!findwithholdDetailResult.htm?flag=1") ;
	        }
	    });
}

后端接收:

String jsonData = RequestUtil.getRequestParam("datalistBill");
    	   List dataList =JSON.parseArray(jsonData, CompanyLaborSalaryAdd.class);

你可能感兴趣的:(前端,java后端)