Support for multiple default content types
Enhance FixedContentNegotiationStrategy and places where it is exposed to also accept a list of media types. Issue: SPR-15367
This commit is contained in:
committed by
Rossen Stoyanchev
parent
95e78b16f7
commit
4a890226ea
@@ -15,8 +15,10 @@
|
||||
*/
|
||||
package org.springframework.web.servlet.config.annotation;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.servlet.ServletContext;
|
||||
|
||||
import org.springframework.http.MediaType;
|
||||
@@ -218,11 +220,18 @@ public class ContentNegotiationConfigurer {
|
||||
|
||||
/**
|
||||
* Set the default content type to use when no content type is requested.
|
||||
* <p>By default this is not set.
|
||||
* <p>
|
||||
* Media types are ordered in the same manner as a "quality" parameter on incoming
|
||||
* requests. If destinations which do not support any of the media types provided are
|
||||
* present, end the list with {@link MediaType#ALL} to allow standard media type
|
||||
* determination
|
||||
* <p>
|
||||
* By default this is not set.
|
||||
*
|
||||
* @see #defaultContentTypeStrategy
|
||||
*/
|
||||
public ContentNegotiationConfigurer defaultContentType(MediaType defaultContentType) {
|
||||
this.factory.setDefaultContentType(defaultContentType);
|
||||
public ContentNegotiationConfigurer defaultContentType(MediaType... defaultContentTypes) {
|
||||
this.factory.setDefaultContentType(Arrays.asList(defaultContentTypes));
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user