Package org.springframework.web.accept
Class HeaderContentNegotiationStrategy
- java.lang.Object
- org.springframework.web.accept.HeaderContentNegotiationStrategy
- All Implemented Interfaces:
ContentNegotiationStrategy
public class HeaderContentNegotiationStrategy extends Object implements ContentNegotiationStrategy
AContentNegotiationStrategy
that checks the 'Accept' request header.- Since:
- 3.2
- Author:
- Rossen Stoyanchev, Juergen Hoeller
Constructor Summary
Constructors Constructor Description HeaderContentNegotiationStrategy()
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description List<MediaType>
resolveMediaTypes(NativeWebRequest request)
Resolve the given request to a list of media types.
Constructor Detail
HeaderContentNegotiationStrategy
public HeaderContentNegotiationStrategy()
Method Detail
resolveMediaTypes
public List<MediaType> resolveMediaTypes(NativeWebRequest request) throws HttpMediaTypeNotAcceptableException
Resolve the given request to a list of media types. The returned list is ordered by specificity first and by quality parameter second.- Specified by:
resolveMediaTypes
in interfaceContentNegotiationStrategy
- Parameters:
request
- the current request- Returns:
- the requested media types or an empty list (never
null
) - Throws:
HttpMediaTypeNotAcceptableException
- if the 'Accept' header cannot be parsed