-
org.springframework.web.HttpMediaTypeNotSupportedException: Content type 'application/x-www-form-urlencoded;charset=UTF-8' not supported포트폴리오 (웹 개발)/계좌관리 웹애플리케이션 2023. 7. 22. 17:19
에러:
7월 23, 2023 4:18:50 오전 org.springframework.web.servlet.handler.AbstractHandlerExceptionResolver logException
경고: Resolved [org.springframework.web.HttpMediaTypeNotSupportedException: Content type 'application/x-www-form-urlencoded;charset=UTF-8' not supported]
원인:
$.ajax({
url:"accountDelete.json",
type:"post",
data:JSON.stringify(data),
dataType:"json",
success:function(rslt){
console.log(rslt);
showAccountList();
}
});
ajax 호출후 받는 데이터타입(contentType)을 명시해주지 않아,
default값인 'application/x-www-form-urlencoded;charset=UTF-8' 가 되어 문제인듯 싶다.
ajax 호출 옵션에 contentType:"application/json" 도 추가해주었다.
해결:
$.ajax({
url:"accountDelete.json",
type:"post",
data:JSON.stringify(data),
dataType:"json",
contentType:"application/json",
success:function(rslt){
console.log(rslt);
showAccountList();
}
});
==> contentType:"application/json" 를 추가해주니 정상 해결되었다.
'포트폴리오 (웹 개발) > 계좌관리 웹애플리케이션' 카테고리의 다른 글
Uncaught ReferenceError: $ is not defined (0) 2023.07.25 erd, 화면 스토리 보드, url 설계 (0) 2023.07.23 <img src=""> 이미지 경로. 로드 안됨. (0) 2023.07.16 org.springframework.dao.EmptyResultDataAccessException (0) 2023.06.27 Server Tomcat v8.5 Server at localhost was unable to start within 90 seconds. (0) 2023.06.26