Example usage for org.springframework.web.servlet.config.annotation ContentNegotiationConfigurer mediaType

List of usage examples for org.springframework.web.servlet.config.annotation ContentNegotiationConfigurer mediaType

Introduction

In this page you can find the example usage for org.springframework.web.servlet.config.annotation ContentNegotiationConfigurer mediaType.

Prototype

public ContentNegotiationConfigurer mediaType(String extension, MediaType mediaType) 

Source Link

Document

Add a mapping from a key, extracted from a path extension or a query parameter, to a MediaType.

Usage

From source file:org.springframework.cloud.config.server.config.ConfigServerMvcConfiguration.java

@Override
public void configureContentNegotiation(ContentNegotiationConfigurer configurer) {
    configurer.mediaType("properties", MediaType.valueOf("text/plain"));
    configurer.mediaType("yml", MediaType.valueOf("text/yaml"));
    configurer.mediaType("yaml", MediaType.valueOf("text/yaml"));
}

From source file:com.torchmind.stockpile.server.configuration.WebMvcConfiguration.java

/**
 * {@inheritDoc}// w ww. ja v  a2 s. c  o  m
 */
@Override
public void configureContentNegotiation(@Nonnull ContentNegotiationConfigurer configurer) {
    configurer.defaultContentType(MediaType.APPLICATION_JSON_UTF8);
    configurer.mediaType("json", MediaType.APPLICATION_JSON_UTF8);
    configurer.mediaType("xml", MediaType.APPLICATION_XML);
    configurer.favorPathExtension(true);
    configurer.ignoreUnknownPathExtensions(true);
    configurer.ignoreAcceptHeader(false);
}

From source file:de.interseroh.report.webconfig.WebMvcConfig.java

@Override
public void configureContentNegotiation(ContentNegotiationConfigurer configurer) {
    configurer.favorPathExtension(false);
    configurer.ignoreAcceptHeader(false);
    configurer.defaultContentType(MediaType.TEXT_PLAIN);

    configurer.mediaType("html", MediaType.TEXT_HTML);
    configurer.mediaType("xml", MediaType.APPLICATION_XML);
}