怎么解决org.springframework.beans.InvalidPropertyException这个异常?
说我这个属性无效、不合法的,没有定义的
org.springframework.beans.InvalidPropertyException: Invalid property 'FEntity[0][FInspectionStandard]' of bean class [com.shunda.light.model.InspectionPlan]
controller是有定义对象的,结果在controller就报上面的错了
public ServerResponse save(InspectionPlan inspectionPlan){
ServerResponse serverResponse = xjService.sumbit(inspectionPlan);
return serverResponse;
}
InspectionPlan 对象有个属性是private List<FEntity> FEntity;FEntity对象属性FInspectionStandard的get/set方法也有,名字也取跟前端一样。但提交就报错了。请问这是怎么回事?
js请求是这样的
let FEntity = [];
for(let i=0,len=that.FXJXMS.length;i<len;++i){
let item = {};
item.FXJXM = that.FXJXMS[i].FXJXM;
item.FInspectionStandard = that.FXJXMS[i].FInspectionStandard;
item.F_STKD_Weight = that.FXJXMS[i].F_STKD_Weight;
item.FIsNormal = "true";
item.FInspectionState = "1";
FEntity.push(item);
}
axios.post('/xj/save',{
'FCheckplanID': that.FXJXMS[0].FCheckplanID,
'FInspectionLocationID': that.FXJXMS[0].FInspectionLocationID,
'FInspectionPlaceID': that.FXJXMS[0].FInspectionPlaceID,
'FXJTypeId': that.FXJXMS[0].FXJTypeId,
'FXJType': that.FXJXMS[0].FXJType,
'FRate': that.FXJXMS[0].FRate,
'FRateUnit': that.FXJXMS[0].FRateUnit,
'FDate': FDate,
'FEntity': FEntity,
},{
headers: {
'Content-Type': 'application/x-www-form-urlencoded'
}
}).then(function (res) {
console.log(res.data)
});
回复
1个回答
test
2024-07-09
要么把FEntity这个字段转成字符串,后台也是用String接收,再转成List;要么前端axios的contentType换成application/json,用json传给后台接收
回复
适合作为回答的
- 经过验证的有效解决办法
- 自己的经验指引,对解决问题有帮助
- 遵循 Markdown 语法排版,代码语义正确
不该作为回答的
- 询问内容细节或回复楼层
- 与题目无关的内容
- “赞”“顶”“同问”“看手册”“解决了没”等毫无意义的内容