diff --git a/spring-web/src/main/java/org/springframework/web/accept/ContentNegotiationManagerFactoryBean.java b/spring-web/src/main/java/org/springframework/web/accept/ContentNegotiationManagerFactoryBean.java index 6b374a8d14..3449fd2688 100644 --- a/spring-web/src/main/java/org/springframework/web/accept/ContentNegotiationManagerFactoryBean.java +++ b/spring-web/src/main/java/org/springframework/web/accept/ContentNegotiationManagerFactoryBean.java @@ -178,20 +178,21 @@ public class ContentNegotiationManagerFactoryBean } /** - * Set the default content type. - *

This content type will be used when neither the request path extension, - * nor a request parameter, nor the {@code Accept} header could help - * determine the requested content type. + * Set the default content type to use when no content type was requested. + *

Note that internally this method creates and adds a + * {@link org.springframework.web.accept.FixedContentNegotiationStrategy + * FixedContentNegotiationStrategy}. Alternatively you can also provide a + * custom strategy via {@link #setDefaultContentTypeStrategy}. */ public void setDefaultContentType(MediaType defaultContentType) { this.defaultNegotiationStrategy = new FixedContentNegotiationStrategy(defaultContentType); } /** - * Set the {@link ContentNegotiationStrategy} to be used to resolving the default content type. - *

This content type will be used when neither the request path extension, - * nor a request parameter, nor the {@code Accept} header could help determine - * the requested content type. + * Configure a custom {@link ContentNegotiationStrategy} to use to determine + * the default content type to use when no content type was requested. + *

However also consider using {@link #setDefaultContentType} which + * provides a simpler alternative to doing the same. * @since 4.1.2 */ public void setDefaultContentTypeStrategy(ContentNegotiationStrategy defaultStrategy) { diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/config/annotation/ContentNegotiationConfigurer.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/config/annotation/ContentNegotiationConfigurer.java index bec231223b..ff34257ada 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/config/annotation/ContentNegotiationConfigurer.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/config/annotation/ContentNegotiationConfigurer.java @@ -158,13 +158,11 @@ public class ContentNegotiationConfigurer { } /** - * Set the default content type. - *

This content type will be used when neither the request path extension, - * nor a request parameter, nor the {@code Accept} header could help determine - * the requested content type. - *

Note that this method achieves the same goal as {@code defaultContentTypeStrategy}, so both - * shouldn't be used at the same time. - * @see #defaultContentTypeStrategy(org.springframework.web.accept.ContentNegotiationStrategy) + * Set the default content type to use when no content type was requested. + *

Note that internally this method creates and adds a + * {@link org.springframework.web.accept.FixedContentNegotiationStrategy + * FixedContentNegotiationStrategy}. Alternatively you can also provide a + * custom strategy via {@link #defaultContentTypeStrategy}. */ public ContentNegotiationConfigurer defaultContentType(MediaType defaultContentType) { this.factoryBean.setDefaultContentType(defaultContentType); @@ -172,14 +170,11 @@ public class ContentNegotiationConfigurer { } /** - * Set the {@link ContentNegotiationStrategy} to be used to resolving the default content type. - *

This content type will be used when neither the request path extension, - * nor a request parameter, nor the {@code Accept} header could help determine - * the requested content type. - *

Note that this method achieves the same goal as {@code defaultContentType}, so both - * shouldn't be used at the same time. + * Configure a custom {@link ContentNegotiationStrategy} to use to determine + * the default content type to use when no content type was requested. + *

However also consider using {@link #defaultContentType} which provides + * a simpler alternative to doing the same. * @since 4.1.2 - * @see #defaultContentType(org.springframework.http.MediaType) */ public ContentNegotiationConfigurer defaultContentTypeStrategy(ContentNegotiationStrategy defaultStrategy) { this.factoryBean.setDefaultContentTypeStrategy(defaultStrategy);