Java Code Examples for org.springframework.web.accept.ServletPathExtensionContentNegotiationStrategy

The following examples show how to use org.springframework.web.accept.ServletPathExtensionContentNegotiationStrategy. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: spring-analysis-note   Source File: ResourceHttpRequestHandler.java    License: MIT License 5 votes vote down vote up
/**
 * Initialize the content negotiation strategy depending on the {@code ContentNegotiationManager}
 * setup and the availability of a {@code ServletContext}.
 * @see ServletPathExtensionContentNegotiationStrategy
 * @see PathExtensionContentNegotiationStrategy
 */
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));
}
 
Example 2
Source Project: java-technology-stack   Source File: ResourceHttpRequestHandler.java    License: MIT License 5 votes vote down vote up
/**
 * Initialize the content negotiation strategy depending on the {@code ContentNegotiationManager}
 * setup and the availability of a {@code ServletContext}.
 * @see ServletPathExtensionContentNegotiationStrategy
 * @see PathExtensionContentNegotiationStrategy
 */
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));
}
 
Example 3
/**
 * Initialize the content negotiation strategy depending on the {@code ContentNegotiationManager}
 * setup and the availability of a {@code ServletContext}.
 * @see ServletPathExtensionContentNegotiationStrategy
 * @see PathExtensionContentNegotiationStrategy
 */
protected PathExtensionContentNegotiationStrategy initContentNegotiationStrategy() {
	Map<String, MediaType> mediaTypes = null;
	if (getContentNegotiationManager() != null) {
		PathExtensionContentNegotiationStrategy strategy =
				getContentNegotiationManager().getStrategy(PathExtensionContentNegotiationStrategy.class);
		if (strategy != null) {
			mediaTypes = new HashMap<String, MediaType>(strategy.getMediaTypes());
		}
	}
	return (getServletContext() != null ?
			new ServletPathExtensionContentNegotiationStrategy(getServletContext(), mediaTypes) :
			new PathExtensionContentNegotiationStrategy(mediaTypes));
}