Java Cannot deserialize instance of `xxx` out of START_ARRAY token问题解决

红太狼 2022-10-10 12:38 233阅读 0赞

问题描述:

org.springframework.http.converter.HttpMessageNotReadableException: JSON parse error: Cannot deserialize instance of `java.lang.String` out of START_ARRAY token; nested exception is com.fasterxml.jackson.databind.exc.MismatchedInputException: Cannot deserialize instance of `java.lang.String` out of START_ARRAY token
at [Source: (PushbackInputStream); line: 1, column: 100] (through reference chain: com.dto.UserDto[“userId”])

问题分析:

1、后端接收参数类型是字符串,但是前端传参类型是数组,前端传参类型和后端参数类型不一致,导致报错。

解决办法:

前端传参类型改为字符串。

2、后端接收参数类型为List,但是前端传参类型为json,前端传参类型和后端参数类型不一致,导致报错。

解决办法:前端使用正确的数组传参格式即可。

  1. [
  2. "344152905613578240"
  3. ]

发表评论

表情:
评论列表 (有 0 条评论,233人围观)

还没有评论,来说两句吧...

相关阅读