스프링 부트 프로젝트에서 json을 읽으려고합니다.springboot deserialize 할 수 없습니다 -HttpMessageNotReadableException
[{
"userId":"101"
},
{
"partNum":"aaa"
},
{
"partNum":"bbb"
},
{
"partNum":"ccc"
}]
나는 DTO 클래스를 만들었습니다 :
public class TcPartDto {
private String userId;
private List<String> partNum;
public String getUserId() {
return userId;
}
public void setUserId(String userId) {
this.userId = userId;
}
public List<String> getPartNum() {
return partNum;
}
}
를 다음과 같이 내 컨트롤러에 호출하고 다음과 같이
내 JSON 데이터는
@RequestMapping(value = "/volumeinfo", method = RequestMethod.POST, consumes = {"application/json"}, produces = {"application/json"})
@ResponseBody
public List<TcPartVolumeDto> volumeinfo(@RequestBody TcPartDto partList) throws Exception {
return tcService.fetchVolumeInfo(partList);
}
하지만 다음 오류가 발생합니다.
우체부을 통해이 오류를 얻을 :
내가 뭐하는 거지 무슨 문제"Could not read document: Can not deserialize instance of tc.service.model.TcPartDto out of START_ARRAY token\n at [Source: [email protected]; line: 1, column: 1]; nested exception is com.fasterxml.jackson.databind.JsonMappingException: Can not deserialize instance of tc.service.model.TcPartDto out of START_ARRAY token\n at [Source: [email protected]; line: 1, column: 1]"
?
이것은 저에게 적합합니다! 감사 –