public class ContentNegotiationConfigurer extends ObjectSE
ContentNegotiationManager を作成し、1 つ以上の ContentNegotiationStrategy インスタンスで構成します。別の方法として、このビルダーのメソッドを使用してオンまたはオフにしたりカスタマイズしたりできる、以下で説明するデフォルトのセットに依存することもできます。
戦略が設定される順序は固定されており、オンまたはオフにすることしかできません。
パス拡張とパラメーター戦略については、MediaType mappings を明示的に追加できます。これらは、パス拡張や "json" などのクエリパラメーター値を "application/json" などの具体的なメディア型に解決するために使用されます。
パス拡張戦略では、ServletContext.getMimeType(java.lang.String)EE と Java Activation Framework (JAF) (使用可能な場合) も使用して、パス拡張を MediaType に解決します。ただし、JAF の使用は suppress にすることができます。
ContentNegotiationManagerFactoryBean| コンストラクターと説明 |
|---|
ContentNegotiationConfigurer(ServletContextEE servletContext)ServletContextEE を使用したクラスコンストラクター。 |
cloneSE, equalsSE, finalizeSE, getClassSE, hashCodeSE, notifySE, notifyAllSE, toStringSE, waitSE, waitSE, waitSEpublic ContentNegotiationConfigurer(ServletContextEE servletContext)
ServletContextEE を使用したクラスコンストラクター。public ContentNegotiationConfigurer favorPathExtension(boolean favorPathExtension)
デフォルトでは、これは true に設定されます。その場合、/hotels.pdf のリクエストは、"Accept" ヘッダーに関係なく "application/pdf" のリクエストとして解釈されます。
public ContentNegotiationConfigurer mediaType(StringSE extension, MediaType mediaType)
パス拡張戦略では、パス拡張を解決するために ServletContext.getMimeType(java.lang.String)EE と JAF (存在する場合) も使用しようとします。この動作を変更するには、useJaf(boolean) プロパティを参照してください。
extension - 見上げる鍵 mediaType - メディア型 mediaTypes(Map), replaceMediaTypes(Map)public ContentNegotiationConfigurer mediaTypes(MapSE<StringSE,MediaType> mediaTypes)
public ContentNegotiationConfigurer replaceMediaTypes(MapSE<StringSE,MediaType> mediaTypes)
mediaType(java.lang.String, org.springframework.http.MediaType) に似ていますが、既存のマッピングを置き換えるためのものです。public ContentNegotiationConfigurer ignoreUnknownPathExtensions(boolean ignore)
false に設定すると、一致するものがなければ HttpMediaTypeNotAcceptableException になります。 デフォルトでは、これは true に設定されています。
public ContentNegotiationConfigurer useJaf(boolean useJaf)
favorPathExtension(boolean) が設定されている場合、このプロパティは、パス拡張を特定の MediaType に解決するために JAF(Java Activation フレームワーク)の使用を許可するかどうかを決定します。 デフォルトではこれは設定されていません。その場合、PathExtensionContentNegotiationStrategy は JAF が使用可能な場合は JAF を使用します。
public ContentNegotiationConfigurer favorParameter(boolean favorParameter)
media type mappings を登録する必要があります。 デフォルトでは、これは false に設定されています。
public ContentNegotiationConfigurer parameterName(StringSE parameterName)
favorParameter(boolean) がオンのときに使用するクエリパラメーター名を設定します。 デフォルトのパラメーター名は "format" です。
public ContentNegotiationConfigurer ignoreAcceptHeader(boolean ignoreAcceptHeader)
デフォルトでは、この値は false に設定されています。
public ContentNegotiationConfigurer defaultContentType(MediaType defaultContentType)
デフォルトでは、これは設定されていません。
public ContentNegotiationConfigurer defaultContentTypeStrategy(ContentNegotiationStrategy defaultStrategy)
ContentNegotiationStrategy を設定します。デフォルトでは、これは設定されていません。
defaultContentType(org.springframework.http.MediaType)protected ContentNegotiationManager buildContentNegotiationManager()
ContentNegotiationManager を構築します。ContentNegotiationManagerFactoryBean.getObject()@DeprecatedSE protected ContentNegotiationManager getContentNegotiationManager() throws ExceptionSE
buildContentNegotiationManager() に置き換えられました。ExceptionSE