[handleHttpMessageNotReadableException] ,error : org.springframework.http.converter.HttpMessageNotReadableException: JSON parse error: syntax error, expect {, actual string, fieldName profield, pos 103, line 1, column 104{"time":"1670295724882","id":21601,"profield":"{\"test\":\"nameh8f8Z\"}"}; nested exception is com.alibaba.fastjson.JSONException: syntax error, expect {, actual string, fieldName profield, pos 103, line 1, column 104{"time":"1670295724882","id":21601,"profield":"{\"test\":\"nameh8f8Z\"}"}
原因:我的profield是一个map,但是传入的是一个String profield":"{\"test\":\"nameh8f8Z\"}",改成map方式就行{"time":"1670295724882","id":21601,"profield":{"test":"nameh8f8Z"}}
本文介绍了解决Spring框架中出现的HttpMessageNotReadableException的具体步骤,特别是当JSON数据中的字段类型不匹配时(例如期待Map却收到String)。文章详细解释了如何正确地将JSON字符串转换为期望的数据类型。
5269

被折叠的 条评论
为什么被折叠?



