List of usage examples for org.springframework.web.servlet.config.annotation ContentNegotiationConfigurer defaultContentTypeStrategy
public ContentNegotiationConfigurer defaultContentTypeStrategy(ContentNegotiationStrategy defaultStrategy)
From source file:io.spring.initializr.web.autoconfigure.InitializrWebConfig.java
@Override public void configureContentNegotiation(ContentNegotiationConfigurer configurer) { configurer.defaultContentTypeStrategy(new CommandLineContentNegotiationStrategy()); }
From source file:xyz.lxie.springboot.api.SwaggerAutoConfiguration.java
@Override public void configureContentNegotiation(ContentNegotiationConfigurer configurer) { configurer.favorPathExtension(true).ignoreUnknownPathExtensions(true).favorParameter(false) .ignoreAcceptHeader(true).useJaf(false).defaultContentType(MediaType.APPLICATION_JSON); // this is the key to make spring mvc respond with json result only! configurer.defaultContentTypeStrategy(nativeWebRequest -> { List<MediaType> medias = new ArrayList<>(); medias.add(MediaType.APPLICATION_JSON); return medias; });/*from w w w . j av a2 s . c o m*/ }