后端接收代码
@PostMapping(value = "/updateUser")
public String updateUser(@RequestBody SysUser sysUser) {}
当前端传送多于的参数时报错如下:
Resolved [org.springframework.http.converter.HttpMessageNotReadableException: JSON parse error: Unrecognized field "roleName" (class com.jxwifi.kyc.common.table.sys_user.entity.SysUser), not marked as ignorable; nested exception is com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException: Unrecognized field "roleName" (class com.jxwifi.kyc.common.table.sys_user.entity.SysUser), not marked as ignorable (18 known properties: "remark", "mobile", "userType", "sex", "id", "email", "emailVerifyResult", "userName", "password", "updateTime"])
at [Source: (PushbackInputStream); line: 1, column: 194] (through reference chain:
通过全局配置解决:
通过配置后,有不存在的参数也不会报400错误,这样前后端开发方便多了,前端不需删除不存在的参数就提交可节约大量的时间。