From ffe69a51e197152509458c0ed56bba1d83e87632 Mon Sep 17 00:00:00 2001 From: Rossen Stoyanchev Date: Mon, 11 Nov 2019 12:04:28 +0000 Subject: [PATCH] Javadoc update for content negotiation Closes gh-23409 --- .../ContentNegotiationManagerFactoryBean.java | 44 +++++++++++-------- .../ContentNegotiationConfigurer.java | 43 +++++++++--------- 2 files changed, 48 insertions(+), 39 deletions(-) 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 fe00ab162ad..f49cff63952 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 @@ -1,5 +1,5 @@ /* - * Copyright 2002-2018 the original author or authors. + * Copyright 2002-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -36,49 +36,55 @@ import org.springframework.web.context.ServletContextAware; /** * Factory to create a {@code ContentNegotiationManager} and configure it with - * one or more {@link ContentNegotiationStrategy} instances. + * {@link ContentNegotiationStrategy} instances. * - *

As of 5.0 you can set the exact strategies to use via - * {@link #setStrategies(List)}. - * - *

As an alternative you can also rely on the set of defaults described below - * which can be turned on or off or customized through the methods of this - * builder: + *

This factory offers properties that in turn result in configuring the + * underlying strategies. The table below shows the property names, their + * default settings, as well as the strategies that they help to configure: * * * * + * * - * + * * * - * - * - * + * + * + * + * * * * - * + * + * * * * * - * - * + * + * + * * * * - * - * + * + * + * * * * + * * - * + * * *
Property SetterDefault ValueUnderlying StrategyDefault SettingEnabled Or Not
{@link #setFavorPathExtension}{@link PathExtensionContentNegotiationStrategy Path Extension strategy}On{@link #setFavorPathExtension favorPathExtension}true{@link PathExtensionContentNegotiationStrategy}Enabled
{@link #setFavorParameter favorParameter}{@link ParameterContentNegotiationStrategy Parameter strategy}false{@link ParameterContentNegotiationStrategy}Off
{@link #setIgnoreAcceptHeader ignoreAcceptHeader}{@link HeaderContentNegotiationStrategy Header strategy}Onfalse{@link HeaderContentNegotiationStrategy}Enabled
{@link #setDefaultContentType defaultContentType}{@link FixedContentNegotiationStrategy Fixed content strategy}Not setnull{@link FixedContentNegotiationStrategy}Off
{@link #setDefaultContentTypeStrategy defaultContentTypeStrategy}null{@link ContentNegotiationStrategy}Not setOff
* - * Note: if you must use URL-based content type resolution, + *

As of 5.0 you can set the exact strategies to use via + * {@link #setStrategies(List)}. + * + *

Note: if you must use URL-based content type resolution, * the use of a query parameter is simpler and preferable to the use of a path * extension since the latter can cause issues with URI variables, path * parameters, and URI decoding. Consider setting {@link #setFavorPathExtension} 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 58b100acaaf..6b0c2522ea5 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 @@ -1,5 +1,5 @@ /* - * Copyright 2002-2018 the original author or authors. + * Copyright 2002-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -38,50 +38,53 @@ import org.springframework.web.accept.PathExtensionContentNegotiationStrategy; * Creates a {@code ContentNegotiationManager} and configures it with * one or more {@link ContentNegotiationStrategy} instances. * - *

As of 5.0 you can set the exact strategies to use via - * {@link #strategies(List)}. - * - *

As an alternative you can also rely on the set of defaults described below - * which can be turned on or off or customized through the methods of this - * builder: + *

This factory offers properties that in turn result in configuring the + * underlying strategies. The table below shows the property names, their + * default settings, as well as the strategies that they help to configure: * * * - * + * + * * - * + * * * * - * - * + * + * + * * * * - * + * + * * * * * - * - * + * + * + * * * * - * - * + * + * + * * * * + * * - * + * * *
Configurer PropertyProperty SetterDefault ValueUnderlying StrategyDefault SettingEnabled Or Not
{@link #favorPathExtension}{@link PathExtensionContentNegotiationStrategy Path Extension strategy}Ontrue{@link PathExtensionContentNegotiationStrategy}Enabled
{@link #favorParameter}{@link ParameterContentNegotiationStrategy Parameter strategy}false{@link ParameterContentNegotiationStrategy}Off
{@link #ignoreAcceptHeader}{@link HeaderContentNegotiationStrategy Header strategy}Onfalse{@link HeaderContentNegotiationStrategy}Enabled
{@link #defaultContentType}{@link FixedContentNegotiationStrategy Fixed content strategy}Not setnull{@link FixedContentNegotiationStrategy}Off
{@link #defaultContentTypeStrategy}null{@link ContentNegotiationStrategy}Not setOff
* - *

The order in which strategies are configured is fixed. You can only turn - * them on or off. + *

As of 5.0 you can set the exact strategies to use via + * {@link #strategies(List)}. * - * Note: if you must use URL-based content type resolution, + *

Note: if you must use URL-based content type resolution, * the use of a query parameter is simpler and preferable to the use of a path * extension since the latter can cause issues with URI variables, path * parameters, and URI decoding. Consider setting {@link #favorPathExtension}