Add ContentNegotiationManagerFactoryBean

The new FactoryBean facilitates the creation of a
ContentNegotiationManager in XML configuration.

Issue: SPR-8420
This commit is contained in:
Rossen Stoyanchev
2012-07-21 06:16:42 -04:00
parent 028e15faa3
commit 64d939bb16
6 changed files with 342 additions and 39 deletions

View File

@@ -35,11 +35,10 @@ import org.springframework.web.accept.PathExtensionContentNegotiationStrategy;
/**
* Helps with configuring a {@link ContentNegotiationManager}.
*
* <p>By default the extension of the request path extension is checked first and
* the {@code Accept} is checked second. The path extension check will perform a
* look up in the media types configured via {@link #setMediaTypes(Map)} and
* will also fall back to {@link ServletContext} and the Java Activation Framework
* (if present).
* <p>By default strategies for checking the extension of the request path and
* the {@code Accept} header are registered. The path extension check will perform
* lookups through the {@link ServletContext} and the Java Activation Framework
* (if present) unless {@linkplain #setMediaTypes(Map) media types} are configured.
*
* @author Rossen Stoyanchev
* @since 3.2
@@ -72,6 +71,16 @@ public class ContentNegotiationConfigurer {
return this;
}
/**
* Add mappings from file extensions to media types.
* <p>If this property is not set, the Java Action Framework, if available, may
* still be used in conjunction with {@link #setFavorPathExtension(boolean)}.
*/
public ContentNegotiationConfigurer addMediaType(String extension, MediaType mediaType) {
this.mediaTypes.put(extension, mediaType);
return this;
}
/**
* Add mappings from file extensions to media types.
* <p>If this property is not set, the Java Action Framework, if available, may