1、联合调试的时候,删除操作报个错:
17:54:44.903 [http-nio-8093-exec-3] WARN o.s.w.s.m.s.DefaultHandlerExceptionResolver - Resolved [org.springframework.http.converter.HttpMessageNotReadableException: JSON parse error: Cannot construct instance of `com.xxx.xxxx.entity.XXXXX` (although at least one Creator exists): no int/Int-argument constructor/factory method to deserialize from Number value (37); nested exception is com.fasterxml.jackson.databind.exc.MismatchedInputException: Cannot construct instance of `com.xxx.xxxx.entity.XXXXX` (although at least one Creator exists): no int/Int-argument constructor/factory method to deserialize from Number value (37)<LF> at [Source: (PushbackInputStream); line: 1, column: 1]]
2、这个问题是因为前后端不一致导致:
前端调用的时候,只传了一个id,然后后端的写法是删除的一个实体类的实例
@Override
public int DeleteXXX(XXX xxx) {
return xxxMapper.deleteById(xxx);
}
DeleteXXX(record.id).then((res) => {
if (res.code === 200) {
message.success('删除成功');
onRefresh();
} else {
message.error(res.msg);
}
});
3、解决方法很简单,只要把前端record.id改为record就可以解决。
4、当然也可以将后端的方法改为deleteById(xxx.id);
这个看后端是否可以修改,否则只能前端来处理了。后端通过方法API的时候,一般都会有说明,这个前端只要根据文档来操作即可。