Spring을 배우면서 비동기 실습 진행중 발생한 오류이다.
이 오류가 무엇이냐.
프론트에서 백엔드로 데이터를 전송할때 타입이 잘못되어 발생한 오류라고 한다.
아래는 해당 오류를 발견했다면 확인하면 좋을 만한 글이다.
https://developer.mozilla.org/ko/docs/Web/HTTP/Headers/Content-Type
Content-Type - HTTP | MDN
Content-Type 개체 헤더는 리소스의 media type을 나타내기 위해 사용됩니다.
developer.mozilla.org
https://developer.mozilla.org/ko/docs/Web/HTTP/Headers/Content-Encoding
Content-Encoding - HTTP | MDN
Content-Encoding 개체 헤더는 미디어 타입을 압축하기 위해 사용됩니다. 이 헤더가 존재하면, 그 값은 개체 본문에 어떤 추가적인 컨텐츠 인코딩이 적용될지를 나타냅니다. 그것은 Content-Type 헤더에
developer.mozilla.org
이번 실습에서는 프로젝트에서 ajax로 데이터를 전달할때 발생한 오류이다.
pom.xml에 의존성을 추가해주고
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
</dependency>
추가를 했는데도 오류가 발생했다면
스프링 컨테이너(ds-servlet.xml)에 아래 bean도 추가해주면 된다.
<bean class="org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter">
<property name="messageConverters">
<list>
<bean class="org.springframework.http.converter.json.MappingJackson2HttpMessageConverter"/>
</list>
</property>
</bean>
728x90