[Ajax] HttpMessageNotReadableException: JSON parse error: Unrecognized token 'firstName': was expecting (JSON String, Number, Array, Object or token 'null', 'true' or 'false');
2021. 2. 16. 22:50ㆍCoding
728x90
1
2
|
Resolved [org.springframework.http.converter.HttpMessageNotReadableException: JSON parse error: Unrecognized token 'firstName': was expecting (JSON String, Number, Array, Object or token 'null', 'true' or 'false'); nested exception is com.fasterxml.jackson.core.JsonParseException: Unrecognized token 'firstName': was expecting (JSON String, Number, Array, Object or token 'null', 'true' or 'false')
at [Source: (PushbackInputStream); line: 1, column: 11]]
|
cs |
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
|
providerVo = {
firstName: firstName,
lastName: lastName,
phone: phone,
country: country,
companyName: companyName,
addr1: addr
};
$.ajax({
url: "/update",
data: providerVo,
dataType: 'json',
contentType: 'application/json',
type: 'post'
...
|
cs |
대충 이런 코드에서...
1
2
3
4
5
6
7
8
|
providerVo = JSON.stringify({
firstName: firstName,
lastName: lastName,
phone: phone,
country: country,
companyName: companyName,
addr1: addr
});
|
cs |
data에 해당하는 providerVo에 JSON.stringfy()만 해주면된다.
ajax가 바로 object를 인식못해서 생기는 문제인듯.
json으로 바꿔줘서 해결.
728x90
'Coding' 카테고리의 다른 글
[Web]Modal 관련. (0) | 2021.03.30 |
---|---|
[Web]Tempus Dominus 날짜 가져오기 getDate (0) | 2021.03.30 |
[Web]FormData의 내용을 console.log로 찍기. (0) | 2021.03.19 |
Bootstrap 유용한 class (0) | 2021.03.10 |
[IntelliJ] 추천 Plugin - Code Glance(최신 버전에서는 안됨.) (0) | 2021.03.04 |