package com.dy.common.webUtil;
|
|
import org.springframework.context.annotation.Configuration;
|
import org.springframework.http.MediaType;
|
import org.springframework.web.servlet.config.annotation.ContentNegotiationConfigurer;
|
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
|
@Configuration
|
public class ResponseContentTypeConfig implements WebMvcConfigurer {
|
|
/**
|
* Springboot请求响应头的Content-TypeContent-Type默认是text/plain,
|
* 下面配置请求响应头的Content-TypeContent-Type默认为application/json
|
* @param configurer
|
*/
|
@Override
|
public void configureContentNegotiation(ContentNegotiationConfigurer configurer) {
|
configurer.defaultContentType(MediaType.APPLICATION_JSON);
|
}
|
}
|