삽질 기록-error

전자정부 프레임워크에 JSON 설정 추가

숲별 2024. 12. 17. 15:58
728x90

 

프론트에서

POST http://localhost:8080/api/trace/connected-path 415 (Unsupported Media Type)

 

백에서

2024-12-17 10:26:43,308 WARN [org.springframework.web.servlet.mvc.support.DefaultHandlerExceptionResolver] Resolved exception caused by handler execution: org.springframework.web.HttpMediaTypeNotSupportedException: Content type 'application/json' not supported

 

뒷구르기하면서 봐도 json타입을 제대로 처리하지 못하는 것 같았다.

 

pom.xml에 아래 내용 추가

		<dependency>
			<groupId>com.fasterxml.jackson.core</groupId>
			<artifactId>jackson-databind</artifactId>
			<version>2.13.4</version>
		</dependency>

 

 

dispatcher-servlet.xml에 아래내용 추가

    <bean class="org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter">
        <property name="webBindingInitializer">
            <bean class="egovframework.example.cmmn.web.EgovBindingInitializer"/>
        </property>
        <property name="messageConverters">
	        <list>
	            <bean class="org.springframework.http.converter.json.MappingJackson2HttpMessageConverter" />
	        </list>
	    </property>
    </bean>