問題復(fù)現(xiàn)場景:前端傳參字符串數(shù)組,后端接收報錯
后端代碼示例
@RequestMapping(value = "/setOptUserIdByCommentId", method = RequestMethod.POST)
@ApiOperation("設(shè)置分辦人")
public void setOptUserIdByCommentId(@RequestBody String[] commentIds, String optUserId, String optUserName) {
....
}
前端代碼示例
this.$axios({
method: "post",
url: "/jd/comment/setOptUserIdByCommentId",
data: {
commentids: ids,
optuserid: encodeURI(this.handleUserValue[1]),
optusername: encodeURI(this.optusername)
},
}).then((res) => {
if (res.data.status == 0) {
this.$message.error(res.data.msg)
return
}
this.$message.success('設(shè)置成功!')
this.dialogVisible = false;
});
后端警告內(nèi)容:
Resolved [org.springframework.http.converter.HttpMessageNotReadableException: JSON parse error: Cannot deserialize instance of [Ljava.lang.String;
out of START_OBJECT token; nested exception is com.fasterxml.jackson.databind.exc.MismatchedInputException: Cannot deserialize instance of [Ljava.lang.String;
out of START_OBJECT token at [Source: (PushbackInputStream); line: 1, column: 1]]
文章來源:http://www.zghlxwxcb.cn/news/detail-600937.html
解決方法
根據(jù)后端idea中提示,json解析錯誤。前端將數(shù)組轉(zhuǎn)化成json推送,后端使用字符串接收再進行處理就可以解決。文章來源地址http://www.zghlxwxcb.cn/news/detail-600937.html
到了這里,關(guān)于報錯:參數(shù)導(dǎo)致JSON parse error: Cannot deserialize instance of `[Ljava.lang.String;` out of START_OBJECT to的文章就介紹完了。如果您還想了解更多內(nèi)容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!