ServletPathExtensionContentNegotiationStrategy (Spring Framework 3.2.1.RELEASE API)
Date: 2013-01-24

org.springframework.web.accept

## Class ServletPathExtensionContentNegotiationStrategy

- java.lang.Object
- - org.springframework.web.accept.MappingMediaTypeFileExtensionResolver
  - - org.springframework.web.accept.AbstractMappingContentNegotiationStrategy
    - - org.springframework.web.accept.PathExtensionContentNegotiationStrategy
      - - org.springframework.web.accept.ServletPathExtensionContentNegotiationStrategy

- All Implemented Interfaces:
    ContentNegotiationStrategy, MediaTypeFileExtensionResolver

      public class ServletPathExtensionContentNegotiationStrategy
      extends PathExtensionContentNegotiationStrategy

  An extension of `PathExtensionContentNegotiationStrategy` that uses `ServletContext.getMimeType(String)` as a fallback mechanism when matching a path extension to a media type.
  Since:
    3.2
  Author:
    Rossen Stoyanchev

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `ServletPathExtensionContentNegotiationStrategy(ServletContext servletContext)` Create an instance without any mappings to start with.
    `ServletPathExtensionContentNegotiationStrategy(ServletContext servletContext, Map<String,MediaType> mediaTypes)` Create an instance with the given extension-to-MediaType lookup.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected MediaType` | `handleNoMatch(NativeWebRequest webRequest, String extension)` Look up the given extension via `ServletContext.getMimeType(String)` and if that doesn't help, delegate to the parent implementation.

    - ### Methods inherited from class org.springframework.web.accept.PathExtensionContentNegotiationStrategy

      `getMediaTypeKey, handleMatch, setUseJaf`

    - ### Methods inherited from class org.springframework.web.accept.AbstractMappingContentNegotiationStrategy

      `resolveMediaTypes`

    - ### Methods inherited from class org.springframework.web.accept.MappingMediaTypeFileExtensionResolver

      `addMapping, getAllFileExtensions, lookupMediaType, resolveFileExtensions`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

    - ### Methods inherited from interface org.springframework.web.accept.MediaTypeFileExtensionResolver

      `getAllFileExtensions, resolveFileExtensions`

- - ### Constructor Detail

    - #### ServletPathExtensionContentNegotiationStrategy

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

      Create an instance with the given extension-to-MediaType lookup.
      Throws:
        `IllegalArgumentException` - if a media type string cannot be parsed

    - #### ServletPathExtensionContentNegotiationStrategy

          public ServletPathExtensionContentNegotiationStrategy(ServletContext servletContext)

      Create an instance without any mappings to start with. Mappings may be added later on if any extensions are resolved through `ServletContext.getMimeType(String)` or through the Java Activation framework.

  - ### Method Detail

    - #### handleNoMatch

          protected MediaType handleNoMatch(NativeWebRequest webRequest,
                                String extension)

      Look up the given extension via `ServletContext.getMimeType(String)` and if that doesn't help, delegate to the parent implementation.
      Overrides:
        `handleNoMatch` in class `PathExtensionContentNegotiationStrategy`