Spring boot org.springframework.http.converter.HttpMessageNotReadableException: JSON parse error: Cannot deserialize value of type `java.util.ArrayList<java.util.Map<java.lang.String,java.lang.Object>>` from Object value (token `JsonToken.START_OBJECT`)
2025. 1. 28. 00:50ㆍJava/Spring Boot
Map 형태로 데이터를 보냈는데, List 형태로 데이터를 받아서 에러 발생
Client
Ext.Ajax.request({
url: '/url',
params: {
_csrf: document.getElementById('_csrf').innerText,
},
method: 'POST',
jsonData: {
data: data,
},
success: function(response) {
},
failure: function(response) {
Ext.Msg.alert('Error', 'Failed to save changes.');
console.error('Server error:', response.responseText);
}
});
Data
{
"data": [
{
"a": "abcg",
"b": 123,
}
]
}
Server
@RequestMapping("/url")
public int test(@RequestBody List<Map<String, Object>> data) {
log.debug("-------------");
log.debug(data.toString());
return null;
}
수정: jsonData를 변경
Ext.Ajax.request({
url: '/url',
params: {
_csrf: document.getElementById('_csrf').innerText,
},
method: 'POST',
jsonData: data,
success: function(response) {
},
failure: function(response) {
Ext.Msg.alert('Error', 'Failed to save changes.');
console.error('Server error:', response.responseText);
}
});
'Java > Spring Boot' 카테고리의 다른 글
Spring boot 파일업로드시 413 에러 발생 조치 (0) | 2024.12.30 |
---|---|
Spring boot client IP 가져오기 (0) | 2024.12.29 |
Spring boot bean이 초기화 된 이후 호출 없이 최초로 작동하기 (0) | 2024.12.29 |
Spring boot 로그에 X-Forwarded-For를 통해서 client IP 기록하기 (0) | 2024.12.29 |
Spring boot Caused by: java.lang.Error: Unresolved compilation problem: Value cannot be resolved to a type (0) | 2024.12.29 |