Spring MVC : Property referenced in indexed property path is neither an array nor a List nor a Map

今天写页面的时候,需要通过JSON发送一个list给后端,chrome控制台打印的发送内容没有问题,可是后端接收到的内容解析后变为了:modifySaleList[0][orgCode] =xxx; 百度了好久,终于找到一个非常暴力的解决方案:

前端代码:

var list = {};//创建list集合
$(ids).each(function (index , id) {
		//由id获得对应数据行
		var row = $("#dataGrid").jqGrid("getRowData" , id);

        list["modifySaleList["+index+"].orgCode"] = row.orgCode;
        list["modifySaleList["+index+"].saleNo"] = row.saleNo;
        list["modifySaleList["+index+"].posNo"] = row.posNo;
    });

//ajax提交请求
var jsonData = "modifyDate=" + tmpDate;
        $.ajax({
            type:"POST",
            url:"${ctx}/modifysale/modifySale/saveModifySale?" + jsonData,
            data: list,
            dataType:"json",
            async : false ,
            success:function(result){
                alert(result.msg);
                location.reload();
            },
            error:function () {

            }
        });

后端代码:

    @RequestMapping(value = "saveModifySale")
	@ResponseBody
	public AjaxUtil saveModifySale(String modifyDate , ModifySale modifySale){
		AjaxUtil result = new AjaxUtil();
		String mDate = modifyDate;
		System.out.println(mDate);

		List list = modifySale.getModifySaleList();
		int index = 0;
		for (ModifySale m:list
			 ) {
			String errorMessage = "";
			m.setModifyDate(mDate);
			index = modifySaleService.saveEntity(m);
			if (index == 1){
				result.setAjaxResult(result, "", 0, "保存数据成功");
			}else {
				errorMessage = "修改不成功流水不成功,流水号 = " + m.getSaleNo();
				result.setAjaxResult(result , "" , 2 , errorMessage);
				break;
			}
		}

		return result;
	}

参考文献:https://blog.csdn.net/freeniuniu/article/details/78806508!

感谢:FreeG牛牛的文章帮助!

你可能感兴趣的:(Spring MVC : Property referenced in indexed property path is neither an array nor a List nor a Map)