下面列出了org.springframework.web.servlet.config.annotation.ContentNegotiationConfigurer#defaultContentType ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
@Override
protected void configureContentNegotiation(ContentNegotiationConfigurer configurer) {
configurer.defaultContentType(MediaType.APPLICATION_JSON);
configurer.favorPathExtension(true);
configurer.ignoreAcceptHeader(false);
configurer.mediaType("json", MediaType.APPLICATION_JSON);
configurer.mediaType("jsonp", new MediaType("application", "x-javascript"));
super.configureContentNegotiation(configurer);
}
@Override
protected void configureContentNegotiation(ContentNegotiationConfigurer configurer) {
configurer.defaultContentType(MediaType.APPLICATION_JSON);
configurer.favorPathExtension(true);
configurer.ignoreAcceptHeader(false);
configurer.mediaType("json", MediaType.APPLICATION_JSON);
configurer.mediaType("jsonp", new MediaType("application", "x-javascript"));
super.configureContentNegotiation(configurer);
}
@Override
public void configureContentNegotiation(ContentNegotiationConfigurer configurer) {
configurer.defaultContentType(MediaType.TEXT_HTML);//默认为HTML
}
@Override
public void configureContentNegotiation(ContentNegotiationConfigurer configurer) {
configurer.defaultContentType(MediaType.APPLICATION_JSON_UTF8);
}
@Override
public void configureContentNegotiation(ContentNegotiationConfigurer configurer) {
configurer.defaultContentType(MediaType.APPLICATION_JSON_UTF8);
}
@Override
public void configureContentNegotiation(ContentNegotiationConfigurer configurer) {
configurer.defaultContentType(MediaType.APPLICATION_JSON_UTF8);
}
@Override
public void configureContentNegotiation(ContentNegotiationConfigurer configurer) {
configurer.defaultContentType(MediaType.APPLICATION_JSON);
}
@Override
protected void configureContentNegotiation(ContentNegotiationConfigurer configurer) {
// default to JSON
configurer.defaultContentType(MediaType.APPLICATION_JSON);
}
@Override
public void configureContentNegotiation(ContentNegotiationConfigurer configurer){
configurer.defaultContentType(MediaType.APPLICATION_JSON);
}
@Override
public void configureContentNegotiation(ContentNegotiationConfigurer configurer) {
configurer.defaultContentType(MediaType.APPLICATION_JSON);
}
@Override
public void configureContentNegotiation(ContentNegotiationConfigurer configurer) {
configurer.defaultContentType(MediaType.APPLICATION_JSON);
}
/**
* 配置默认媒体类型
* @author Frodez
* @date 2019-05-10
*/
@Override
public void configureContentNegotiation(ContentNegotiationConfigurer configurer) {
configurer.defaultContentType(MediaType.APPLICATION_JSON);
}