Example usage for org.springframework.web.accept PathExtensionContentNegotiationStrategy getMediaTypes

List of usage examples for org.springframework.web.accept PathExtensionContentNegotiationStrategy getMediaTypes

Introduction

In this page you can find the example usage for org.springframework.web.accept PathExtensionContentNegotiationStrategy getMediaTypes.

Prototype

public Map<String, MediaType> getMediaTypes() 

Source Link

Usage

From source file:org.springframework.web.servlet.resource.ResourceHttpRequestHandler.java

/**
 * Initialize the content negotiation strategy depending on the {@code ContentNegotiationManager}
 * setup and the availability of a {@code ServletContext}.
 * @see ServletPathExtensionContentNegotiationStrategy
 * @see PathExtensionContentNegotiationStrategy
 *///from ww w.j  a v a  2 s . c om
protected PathExtensionContentNegotiationStrategy initContentNegotiationStrategy() {
    Map<String, MediaType> mediaTypes = null;
    if (getContentNegotiationManager() != null) {
        PathExtensionContentNegotiationStrategy strategy = getContentNegotiationManager()
                .getStrategy(PathExtensionContentNegotiationStrategy.class);
        if (strategy != null) {
            mediaTypes = new HashMap<>(strategy.getMediaTypes());
        }
    }
    return (getServletContext() != null
            ? new ServletPathExtensionContentNegotiationStrategy(getServletContext(), mediaTypes)
            : new PathExtensionContentNegotiationStrategy(mediaTypes));
}