Loading...
Spring Framework Reference Documentation 7.0.2의 Content Types의 한국어 번역본입니다.
아래의 경우에 피드백에서 신고해주신다면 반영하겠습니다.
감사합니다 :)
See equivalent in the Reactive stack
요청으로부터 요청된 미디어 타입을 Spring MVC가 어떻게 결정하는지 구성할 수 있습니다
(예를 들어, Accept 헤더, URL 경로 확장자, 쿼리 매개변수 등).
기본적으로는 Accept 헤더만 확인합니다.
URL 기반 콘텐츠 타입 결정 방식을 반드시 사용해야 한다면, 경로 확장자보다 쿼리 매개변수 전략을 사용하는 것을 고려하십시오. 자세한 내용은 Suffix Match 및 Suffix Match and RFD를 참조하십시오.
다음 예제와 같이 요청된 콘텐츠 타입 결정을 커스터마이징할 수 있습니다:
1@Configuration 2public class WebConfiguration implements WebMvcConfigurer { 3 4 @Override 5 public void configureContentNegotiation(ContentNegotiationConfigurer configurer) { 6 configurer.mediaType("json", MediaType.APPLICATION_JSON); 7 configurer.mediaType("xml", MediaType.APPLICATION_XML); 8 } 9}
1@Configuration 2class WebConfiguration : WebMvcConfigurer { 3 4 override fun configureContentNegotiation(configurer: ContentNegotiationConfigurer) { 5 configurer.mediaType("json", MediaType.APPLICATION_JSON) 6 configurer.mediaType("xml", MediaType.APPLICATION_XML) 7 } 8}
1<mvc:annotation-driven content-negotiation-manager="contentNegotiationManager"/> 2 3<bean id="contentNegotiationManager" class="org.springframework.web.accept.ContentNegotiationManagerFactoryBean"> 4 <property name="mediaTypes"> 5 <value> 6 json=application/json 7 xml=application/xml 8 </value> 9 </property> 10</bean>
Interceptors
Message Converters