Example usage for org.springframework.web.accept ServletPathExtensionContentNegotiationStrategy ServletPathExtensionContentNegotiationStrategy

List of usage examples for org.springframework.web.accept ServletPathExtensionContentNegotiationStrategy ServletPathExtensionContentNegotiationStrategy

Introduction

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

Prototype

public ServletPathExtensionContentNegotiationStrategy(ServletContext servletContext,
        @Nullable Map<String, MediaType> mediaTypes) 

Source Link

Document

Create an instance with the given extension-to-MediaType lookup.

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 w w w .  j  a v a  2 s.  c  o  m*/
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));
}