Class ParameterContentNegotiationStrategy

All Implemented Interfaces:
ContentNegotiationStrategy, MediaTypeFileExtensionResolver

public class ParameterContentNegotiationStrategy extends AbstractMappingContentNegotiationStrategy
Strategy that resolves the requested content type from a query parameter. The default query parameter name is "format".

You can register static mappings between keys (i.e. the expected value of the query parameter) and MediaType's via MappingMediaTypeFileExtensionResolver.addMapping(String, MediaType). As of 5.0 this strategy also supports dynamic lookups of keys via MediaTypeFactory.getMediaType(org.springframework.core.io.Resource).

Since:
3.2
Author:
Rossen Stoyanchev
  • Constructor Details

    • ParameterContentNegotiationStrategy

      public ParameterContentNegotiationStrategy(Map<String,MediaType> mediaTypes)
      Create an instance with the given map of file extensions and media types.
  • Method Details