类的使用
org.springframework.http.MediaType
使用MediaType的程序包 程序包 说明 org.springframework.http Contains a basic abstraction over client/server-side HTTP.org.springframework.http.client Contains an abstraction over client-side HTTP.org.springframework.http.codec org.springframework.http.codec.json JSON encoder and decoder support.org.springframework.http.codec.multipart Multipart support.org.springframework.http.codec.protobuf Provides an encoder and a decoder for Google Protocol Buffers.org.springframework.http.converter Provides an HttpMessageConverter abstraction to convert between Java objects and HTTP input/output messages.org.springframework.http.converter.feed Provides HttpMessageConverter implementations for handling Atom and RSS feeds.org.springframework.http.converter.json Provides HttpMessageConverter implementations for handling JSON.org.springframework.http.converter.protobuf Provides an HttpMessageConverter implementation for handling Google Protocol Buffers.org.springframework.http.converter.xml Provides HttpMessageConverter implementations for handling XML.org.springframework.mock.http.server.reactive Mock implementations of reactive HTTP server contracts.org.springframework.mock.web A comprehensive set of Servlet API 4.0 mock objects, targeted at usage with Spring's Web MVC framework.org.springframework.test.web.client.match Contains built-inRequestMatcher
implementations.org.springframework.test.web.client.response Contains built-inResponseCreator
implementations.org.springframework.test.web.reactive.server Support for testing Spring WebFlux server endpoints viaWebTestClient
.org.springframework.test.web.servlet.request Contains built-inRequestBuilder
implementations.org.springframework.test.web.servlet.result Contains built-inResultMatcher
andResultHandler
implementations.org.springframework.web Common, generic interfaces that define minimal boundary points between Spring's web infrastructure and other framework modules.org.springframework.web.accept This package contains classes used to determine the requested the media types in a request.org.springframework.web.client Core package of the client-side web support.org.springframework.web.reactive.accept RequestedContentTypeResolver
strategy and implementations to resolve the requested content type for a given request.org.springframework.web.reactive.function Provides a foundation for both the reactive client and server subpackages.org.springframework.web.reactive.function.client Provides a reactiveWebClient
that builds on top of theorg.springframework.http.client.reactive
reactive HTTP adapter layer.org.springframework.web.reactive.function.client.support Classes supporting theorg.springframework.web.reactive.function.client
package.org.springframework.web.reactive.function.server Provides the types that make up Spring's functional web framework for Reactive environments.org.springframework.web.reactive.function.server.support Classes supporting theorg.springframework.web.reactive.function.server
package.org.springframework.web.reactive.resource Support classes for serving static resources.org.springframework.web.reactive.result Support for various programming model styles including the invocation of different types of handlers, e.g. annotated controller vs simple WebHandler, including the handling of handler result values, e.g.org.springframework.web.reactive.result.condition RequestCondition
and implementations for matching requests based on different criteria.org.springframework.web.reactive.result.view Support for result handling through view resolution.org.springframework.web.reactive.result.view.freemarker Support classes for the integration of FreeMarker as Spring web view technology.org.springframework.web.reactive.result.view.script Support classes for views based on the JSR-223 script engine abstraction (as included in Java 6+), e.g. using JavaScript via Nashorn on JDK 8.org.springframework.web.server Core interfaces and classes for Spring's generic, reactive web support.org.springframework.web.servlet.config.annotation Annotation-based setup for Spring MVC.org.springframework.web.servlet.function Provides the types that make up Spring's functional web framework for Servlet environments.org.springframework.web.servlet.mvc.condition Common MVC logic for matching incoming requests based on conditions.org.springframework.web.servlet.mvc.method.annotation MVC infrastructure for annotation-based handler method processing, building on theorg.springframework.web.method.annotation
package.org.springframework.web.servlet.resource Support classes for serving static resources.org.springframework.web.servlet.view Provides standard View and ViewResolver implementations, including abstract base classes for custom implementations.org.springframework.web.socket.sockjs.transport.handler TransportHandler
implementation classes as well as a concreteSockJsService
.org.springframework.http中MediaType的使用
声明为MediaType的org.springframework.http中的字段 修饰符和类型 字段 说明 static MediaType
MediaType. ALL
Public constant media type that includes all media ranges (i.estatic MediaType
MediaType. APPLICATION_ATOM_XML
Public constant media type forapplication/atom+xml
.static MediaType
MediaType. APPLICATION_CBOR
Public constant media type forapplication/cbor
.static MediaType
MediaType. APPLICATION_FORM_URLENCODED
Public constant media type forapplication/x-www-form-urlencoded
.static MediaType
MediaType. APPLICATION_JSON
Public constant media type forapplication/json
.static MediaType
MediaType. APPLICATION_JSON_UTF8
已过时。as of 5.2 in favor ofAPPLICATION_JSON
since major browsers like Chrome now comply with the specification and interpret correctly UTF-8 special characters without requiring acharset=UTF-8
parameter.static MediaType
MediaType. APPLICATION_OCTET_STREAM
Public constant media type forapplication/octet-stream
.static MediaType
MediaType. APPLICATION_PDF
Public constant media type forapplication/pdf
.static MediaType
MediaType. APPLICATION_PROBLEM_JSON
Public constant media type forapplication/problem+json
.static MediaType
MediaType. APPLICATION_PROBLEM_JSON_UTF8
已过时。as of 5.2 in favor ofAPPLICATION_PROBLEM_JSON
since major browsers like Chrome now comply with the specification and interpret correctly UTF-8 special characters without requiring acharset=UTF-8
parameter.static MediaType
MediaType. APPLICATION_PROBLEM_XML
Public constant media type forapplication/problem+xml
.static MediaType
MediaType. APPLICATION_RSS_XML
Public constant media type forapplication/rss+xml
.static MediaType
MediaType. APPLICATION_STREAM_JSON
Public constant media type forapplication/stream+json
.static MediaType
MediaType. APPLICATION_XHTML_XML
Public constant media type forapplication/xhtml+xml
.static MediaType
MediaType. APPLICATION_XML
Public constant media type forapplication/xml
.static MediaType
MediaType. IMAGE_GIF
Public constant media type forimage/gif
.static MediaType
MediaType. IMAGE_JPEG
Public constant media type forimage/jpeg
.static MediaType
MediaType. IMAGE_PNG
Public constant media type forimage/png
.static MediaType
MediaType. MULTIPART_FORM_DATA
Public constant media type formultipart/form-data
.static MediaType
MediaType. MULTIPART_MIXED
Public constant media type formultipart/mixed
.static MediaType
MediaType. MULTIPART_RELATED
Public constant media type formultipart/related
.static MediaType
MediaType. TEXT_EVENT_STREAM
Public constant media type fortext/event-stream
.static MediaType
MediaType. TEXT_HTML
Public constant media type fortext/html
.static MediaType
MediaType. TEXT_MARKDOWN
Public constant media type fortext/markdown
.static MediaType
MediaType. TEXT_PLAIN
Public constant media type fortext/plain
.static MediaType
MediaType. TEXT_XML
Public constant media type fortext/xml
.类型参数类型为MediaType的org.springframework.http中的字段 修饰符和类型 字段 说明 static Comparator<MediaType>
MediaType. QUALITY_VALUE_COMPARATOR
Comparator used bysortByQualityValue(List)
.static Comparator<MediaType>
MediaType. SPECIFICITY_COMPARATOR
Comparator used bysortBySpecificity(List)
.返回MediaType的org.springframework.http中的方法 修饰符和类型 方法 说明 static MediaType
MediaType. asMediaType(MimeType mimeType)
Re-create the given mime type as a media type.MediaType
MediaType. copyQualityValue(MediaType mediaType)
Return a replica of this instance with the quality value of the givenMediaType
.MediaType
HttpHeaders. getContentType()
Return the media type of the body, as specified by theContent-Type
header.static MediaType
MediaType. parseMediaType(String mediaType)
Parse the given String into a singleMediaType
.MediaType
MediaType. removeQualityValue()
Return a replica of this instance with its quality value removed.static MediaType
MediaType. valueOf(String value)
Parse the given String value into aMediaType
object, with this method name following the 'valueOf' naming convention (as supported byConversionService
.返回变量类型为MediaType的类型的org.springframework.http中的方法 修饰符和类型 方法 说明 static List<MediaType>
MediaType. asMediaTypes(List<MimeType> mimeTypes)
Re-create the given mime types as media types.List<MediaType>
HttpHeaders. getAccept()
Return the list of acceptable media types, as specified by theAccept
header.static Optional<MediaType>
MediaTypeFactory. getMediaType(String filename)
Determine a media type for the given file name, if possible.static Optional<MediaType>
MediaTypeFactory. getMediaType(Resource resource)
Determine a media type for the given resource, if possible.static List<MediaType>
MediaTypeFactory. getMediaTypes(String filename)
Determine the media types for the given file name, if possible.static List<MediaType>
MediaType. parseMediaTypes(String mediaTypes)
Parse the comma-separated string into a list ofMediaType
objects.static List<MediaType>
MediaType. parseMediaTypes(List<String> mediaTypes)
Parse the given list of (potentially) comma-separated strings into a list ofMediaType
objects.参数类型为MediaType的org.springframework.http中的方法 修饰符和类型 方法 说明 B
RequestEntity.HeadersBuilder. accept(MediaType... acceptableMediaTypes)
Set the list of acceptable media types, as specified by theAccept
header.RequestEntity.BodyBuilder
RequestEntity.BodyBuilder. contentType(MediaType contentType)
Set the media type of the body, as specified by theContent-Type
header.ResponseEntity.BodyBuilder
ResponseEntity.BodyBuilder. contentType(MediaType contentType)
Set the media type of the body, as specified by theContent-Type
header.MediaType
MediaType. copyQualityValue(MediaType mediaType)
Return a replica of this instance with the quality value of the givenMediaType
.boolean
MediaType. includes(MediaType other)
Indicate whether thisMediaType
includes the given media type.boolean
MediaType. isCompatibleWith(MediaType other)
Indicate whether thisMediaType
is compatible with the given media type.void
HttpHeaders. setContentType(MediaType mediaType)
Set the media type of the body, as specified by theContent-Type
header.类型变量类型为MediaType的org.springframework.http中的方法参数 修饰符和类型 方法 说明 void
HttpHeaders. setAccept(List<MediaType> acceptableMediaTypes)
Set the list of acceptable media types, as specified by theAccept
header.static void
MediaType. sortByQualityValue(List<MediaType> mediaTypes)
Sorts the given list ofMediaType
objects by quality value.static void
MediaType. sortBySpecificity(List<MediaType> mediaTypes)
Sorts the given list ofMediaType
objects by specificity.static void
MediaType. sortBySpecificityAndQuality(List<MediaType> mediaTypes)
Sorts the given list ofMediaType
objects by specificity as the primary criteria and quality value the secondary.static String
MediaType. toString(Collection<MediaType> mediaTypes)
Return a string representation of the given list ofMediaType
objects.参数类型为MediaType的org.springframework.http中的构造器 构造器 说明 MediaType(MediaType other, Charset charset)
Copy-constructor that copies the type, subtype and parameters of the givenMediaType
, and allows to set the specified character set.MediaType(MediaType other, Map<String,String> parameters)
Copy-constructor that copies the type and subtype of the givenMediaType
, and allows for different parameters.org.springframework.http.client中MediaType的使用
参数类型为MediaType的org.springframework.http.client中的方法 修饰符和类型 方法 说明 MultipartBodyBuilder.PartBuilder
MultipartBodyBuilder.PartBuilder. contentType(MediaType contentType)
Set the media type of the part.MultipartBodyBuilder.PartBuilder
MultipartBodyBuilder. part(String name, Object part, MediaType contentType)
Variant ofMultipartBodyBuilder.part(String, Object)
that also accepts a MediaType.org.springframework.http.codec中MediaType的使用
返回MediaType的org.springframework.http.codec中的方法 修饰符和类型 方法 说明 protected MediaType
DecoderHttpMessageReader. getContentType(HttpMessage inputMessage)
Determine the Content-Type of the HTTP message based on the "Content-Type" header or otherwise default toAPPLICATION_OCTET_STREAM
.protected MediaType
FormHttpMessageWriter. getMediaType(MediaType mediaType)
返回变量类型为MediaType的类型的org.springframework.http.codec中的方法 修饰符和类型 方法 说明 List<MediaType>
DecoderHttpMessageReader. getReadableMediaTypes()
List<MediaType>
FormHttpMessageReader. getReadableMediaTypes()
List<MediaType>
HttpMessageReader. getReadableMediaTypes()
Return theMediaType
's that this reader supports.List<MediaType>
ServerSentEventHttpMessageReader. getReadableMediaTypes()
List<MediaType>
HttpMessageEncoder. getStreamingMediaTypes()
Return "streaming" media types for which flushing should be performed automatically vs at the end of the input stream.List<MediaType>
EncoderHttpMessageWriter. getWritableMediaTypes()
List<MediaType>
FormHttpMessageWriter. getWritableMediaTypes()
List<MediaType>
HttpMessageWriter. getWritableMediaTypes()
Return theMediaType
's that this writer supports.List<MediaType>
ResourceHttpMessageWriter. getWritableMediaTypes()
List<MediaType>
ServerSentEventHttpMessageWriter. getWritableMediaTypes()
参数类型为MediaType的org.springframework.http.codec中的方法 修饰符和类型 方法 说明 boolean
DecoderHttpMessageReader. canRead(ResolvableType elementType, MediaType mediaType)
boolean
FormHttpMessageReader. canRead(ResolvableType elementType, MediaType mediaType)
boolean
HttpMessageReader. canRead(ResolvableType elementType, MediaType mediaType)
Whether the given object type is supported by this reader.boolean
ServerSentEventHttpMessageReader. canRead(ResolvableType elementType, MediaType mediaType)
boolean
EncoderHttpMessageWriter. canWrite(ResolvableType elementType, MediaType mediaType)
boolean
FormHttpMessageWriter. canWrite(ResolvableType elementType, MediaType mediaType)
boolean
HttpMessageWriter. canWrite(ResolvableType elementType, MediaType mediaType)
Whether the given object type is supported by this writer.boolean
ResourceHttpMessageWriter. canWrite(ResolvableType elementType, MediaType mediaType)
boolean
ServerSentEventHttpMessageWriter. canWrite(ResolvableType elementType, MediaType mediaType)
default Map<String,Object>
HttpMessageEncoder. getEncodeHints(ResolvableType actualType, ResolvableType elementType, MediaType mediaType, ServerHttpRequest request, ServerHttpResponse response)
Get decoding hints based on the server request or annotations on the target controller method parameter.protected MediaType
FormHttpMessageWriter. getMediaType(MediaType mediaType)
protected Map<String,Object>
EncoderHttpMessageWriter. getWriteHints(ResolvableType streamType, ResolvableType elementType, MediaType mediaType, ServerHttpRequest request, ServerHttpResponse response)
Get additional hints for encoding for example based on the server request or annotations from controller method parameters.reactor.core.publisher.Mono<Void>
EncoderHttpMessageWriter. write(org.reactivestreams.Publisher<? extends T> inputStream, ResolvableType actualType, ResolvableType elementType, MediaType mediaType, ServerHttpRequest request, ServerHttpResponse response, Map<String,Object> hints)
reactor.core.publisher.Mono<Void>
EncoderHttpMessageWriter. write(org.reactivestreams.Publisher<? extends T> inputStream, ResolvableType elementType, MediaType mediaType, ReactiveHttpOutputMessage message, Map<String,Object> hints)
reactor.core.publisher.Mono<Void>
FormHttpMessageWriter. write(org.reactivestreams.Publisher<? extends MultiValueMap<String,String>> inputStream, ResolvableType elementType, MediaType mediaType, ReactiveHttpOutputMessage message, Map<String,Object> hints)
default reactor.core.publisher.Mono<Void>
HttpMessageWriter. write(org.reactivestreams.Publisher<? extends T> inputStream, ResolvableType actualType, ResolvableType elementType, MediaType mediaType, ServerHttpRequest request, ServerHttpResponse response, Map<String,Object> hints)
Server-side only alternative toHttpMessageWriter.write(Publisher, ResolvableType, MediaType, ReactiveHttpOutputMessage, Map)
with additional context available.reactor.core.publisher.Mono<Void>
HttpMessageWriter. write(org.reactivestreams.Publisher<? extends T> inputStream, ResolvableType elementType, MediaType mediaType, ReactiveHttpOutputMessage message, Map<String,Object> hints)
Write an given stream of object to the output message.reactor.core.publisher.Mono<Void>
ResourceHttpMessageWriter. write(org.reactivestreams.Publisher<? extends Resource> inputStream, ResolvableType actualType, ResolvableType elementType, MediaType mediaType, ServerHttpRequest request, ServerHttpResponse response, Map<String,Object> hints)
reactor.core.publisher.Mono<Void>
ResourceHttpMessageWriter. write(org.reactivestreams.Publisher<? extends Resource> inputStream, ResolvableType elementType, MediaType mediaType, ReactiveHttpOutputMessage message, Map<String,Object> hints)
reactor.core.publisher.Mono<Void>
ServerSentEventHttpMessageWriter. write(org.reactivestreams.Publisher<?> input, ResolvableType actualType, ResolvableType elementType, MediaType mediaType, ServerHttpRequest request, ServerHttpResponse response, Map<String,Object> hints)
reactor.core.publisher.Mono<Void>
ServerSentEventHttpMessageWriter. write(org.reactivestreams.Publisher<?> input, ResolvableType elementType, MediaType mediaType, ReactiveHttpOutputMessage message, Map<String,Object> hints)
org.springframework.http.codec.json中MediaType的使用
返回变量类型为MediaType的类型的org.springframework.http.codec.json中的方法 修饰符和类型 方法 说明 List<MediaType>
AbstractJackson2Encoder. getStreamingMediaTypes()
参数类型为MediaType的org.springframework.http.codec.json中的方法 修饰符和类型 方法 说明 Map<String,Object>
AbstractJackson2Encoder. getEncodeHints(ResolvableType actualType, ResolvableType elementType, MediaType mediaType, ServerHttpRequest request, ServerHttpResponse response)
类型变量类型为MediaType的org.springframework.http.codec.json中的方法参数 修饰符和类型 方法 说明 void
AbstractJackson2Encoder. setStreamingMediaTypes(List<MediaType> mediaTypes)
Configure "streaming" media types for which flushing should be performed automatically vs at the end of the stream.org.springframework.http.codec.multipart中MediaType的使用
返回变量类型为MediaType的类型的org.springframework.http.codec.multipart中的方法 修饰符和类型 方法 说明 List<MediaType>
MultipartHttpMessageReader. getReadableMediaTypes()
List<MediaType>
SynchronossPartHttpMessageReader. getReadableMediaTypes()
List<MediaType>
MultipartHttpMessageWriter. getWritableMediaTypes()
参数类型为MediaType的org.springframework.http.codec.multipart中的方法 修饰符和类型 方法 说明 boolean
MultipartHttpMessageReader. canRead(ResolvableType elementType, MediaType mediaType)
boolean
SynchronossPartHttpMessageReader. canRead(ResolvableType elementType, MediaType mediaType)
boolean
MultipartHttpMessageWriter. canWrite(ResolvableType elementType, MediaType mediaType)
reactor.core.publisher.Mono<Void>
MultipartHttpMessageWriter. write(org.reactivestreams.Publisher<? extends MultiValueMap<String,?>> inputStream, ResolvableType elementType, MediaType mediaType, ReactiveHttpOutputMessage outputMessage, Map<String,Object> hints)
org.springframework.http.codec.protobuf中MediaType的使用
返回变量类型为MediaType的类型的org.springframework.http.codec.protobuf中的方法 修饰符和类型 方法 说明 List<MediaType>
ProtobufEncoder. getStreamingMediaTypes()
参数类型为MediaType的org.springframework.http.codec.protobuf中的方法 修饰符和类型 方法 说明 reactor.core.publisher.Mono<Void>
ProtobufHttpMessageWriter. write(org.reactivestreams.Publisher<? extends com.google.protobuf.Message> inputStream, ResolvableType elementType, MediaType mediaType, ReactiveHttpOutputMessage message, Map<String,Object> hints)
org.springframework.http.converter中MediaType的使用
返回MediaType的org.springframework.http.converter中的方法 修饰符和类型 方法 说明 protected MediaType
AbstractHttpMessageConverter. getDefaultContentType(T t)
Returns the default content type for the given type.MediaType
BufferedImageHttpMessageConverter. getDefaultContentType()
Returns the defaultContent-Type
to be used for writing.protected MediaType
ResourceHttpMessageConverter. getDefaultContentType(Resource resource)
protected MediaType
ResourceRegionHttpMessageConverter. getDefaultContentType(Object object)
protected MediaType
FormHttpMessageConverter. getFormContentType(MediaType contentType)
Return the content type used to write forms, given the preferred content type.返回变量类型为MediaType的类型的org.springframework.http.converter中的方法 修饰符和类型 方法 说明 List<MediaType>
AbstractHttpMessageConverter. getSupportedMediaTypes()
List<MediaType>
BufferedImageHttpMessageConverter. getSupportedMediaTypes()
List<MediaType>
FormHttpMessageConverter. getSupportedMediaTypes()
Return the list ofMediaType
objects supported by this converter.List<MediaType>
HttpMessageConverter. getSupportedMediaTypes()
Return the list ofMediaType
objects supported by this converter.参数类型为MediaType的org.springframework.http.converter中的方法 修饰符和类型 方法 说明 protected void
AbstractHttpMessageConverter. addDefaultHeaders(HttpHeaders headers, T t, MediaType contentType)
Add default headers to the output message.protected void
StringHttpMessageConverter. addDefaultHeaders(HttpHeaders headers, String s, MediaType type)
void
FormHttpMessageConverter. addSupportedMediaTypes(MediaType... supportedMediaTypes)
AddMediaType
objects to be supported by this converter.boolean
AbstractGenericHttpMessageConverter. canRead(Type type, Class<?> contextClass, MediaType mediaType)
boolean
AbstractHttpMessageConverter. canRead(Class<?> clazz, MediaType mediaType)
This implementation checks if the given class is supported, and if the supported media typesinclude the given media type.protected boolean
AbstractHttpMessageConverter. canRead(MediaType mediaType)
boolean
BufferedImageHttpMessageConverter. canRead(Class<?> clazz, MediaType mediaType)
boolean
FormHttpMessageConverter. canRead(Class<?> clazz, MediaType mediaType)
boolean
GenericHttpMessageConverter. canRead(Type type, Class<?> contextClass, MediaType mediaType)
Indicates whether the given type can be read by this converter.boolean
HttpMessageConverter. canRead(Class<?> clazz, MediaType mediaType)
Indicates whether the given class can be read by this converter.boolean
ObjectToStringHttpMessageConverter. canRead(Class<?> clazz, MediaType mediaType)
boolean
ResourceRegionHttpMessageConverter. canRead(Class<?> clazz, MediaType mediaType)
boolean
ResourceRegionHttpMessageConverter. canRead(Type type, Class<?> contextClass, MediaType mediaType)
boolean
AbstractGenericHttpMessageConverter. canWrite(Type type, Class<?> clazz, MediaType mediaType)
boolean
AbstractHttpMessageConverter. canWrite(Class<?> clazz, MediaType mediaType)
protected boolean
AbstractHttpMessageConverter. canWrite(MediaType mediaType)
Returnstrue
if the given media type includes any of the supported media types.boolean
BufferedImageHttpMessageConverter. canWrite(Class<?> clazz, MediaType mediaType)
boolean
FormHttpMessageConverter. canWrite(Class<?> clazz, MediaType mediaType)
boolean
GenericHttpMessageConverter. canWrite(Type type, Class<?> clazz, MediaType mediaType)
Indicates whether the given class can be written by this converter.boolean
HttpMessageConverter. canWrite(Class<?> clazz, MediaType mediaType)
Indicates whether the given class can be written by this converter.boolean
ObjectToStringHttpMessageConverter. canWrite(Class<?> clazz, MediaType mediaType)
boolean
ResourceRegionHttpMessageConverter. canWrite(Class<?> clazz, MediaType mediaType)
boolean
ResourceRegionHttpMessageConverter. canWrite(Type type, Class<?> clazz, MediaType mediaType)
protected Long
AbstractHttpMessageConverter. getContentLength(T t, MediaType contentType)
Returns the content length for the given type.protected Long
ByteArrayHttpMessageConverter. getContentLength(byte[] bytes, MediaType contentType)
protected Long
ObjectToStringHttpMessageConverter. getContentLength(Object obj, MediaType contentType)
protected Long
ResourceHttpMessageConverter. getContentLength(Resource resource, MediaType contentType)
protected Long
StringHttpMessageConverter. getContentLength(String str, MediaType contentType)
protected MediaType
FormHttpMessageConverter. getFormContentType(MediaType contentType)
Return the content type used to write forms, given the preferred content type.void
BufferedImageHttpMessageConverter. setDefaultContentType(MediaType defaultContentType)
Sets the defaultContent-Type
to be used for writing.void
AbstractGenericHttpMessageConverter. write(T t, Type type, MediaType contentType, HttpOutputMessage outputMessage)
This implementation sets the default headers by callingAbstractHttpMessageConverter.addDefaultHeaders(org.springframework.http.HttpHeaders, T, org.springframework.http.MediaType)
, and then callsAbstractGenericHttpMessageConverter.writeInternal(T, org.springframework.http.HttpOutputMessage)
.void
AbstractHttpMessageConverter. write(T t, MediaType contentType, HttpOutputMessage outputMessage)
This implementation sets the default headers by callingAbstractHttpMessageConverter.addDefaultHeaders(org.springframework.http.HttpHeaders, T, org.springframework.http.MediaType)
, and then callsAbstractHttpMessageConverter.writeInternal(T, org.springframework.http.HttpOutputMessage)
.void
BufferedImageHttpMessageConverter. write(BufferedImage image, MediaType contentType, HttpOutputMessage outputMessage)
void
FormHttpMessageConverter. write(MultiValueMap<String,?> map, MediaType contentType, HttpOutputMessage outputMessage)
void
GenericHttpMessageConverter. write(T t, Type type, MediaType contentType, HttpOutputMessage outputMessage)
Write an given object to the given output message.void
HttpMessageConverter. write(T t, MediaType contentType, HttpOutputMessage outputMessage)
Write an given object to the given output message.类型变量类型为MediaType的org.springframework.http.converter中的方法参数 修饰符和类型 方法 说明 void
AbstractHttpMessageConverter. setSupportedMediaTypes(List<MediaType> supportedMediaTypes)
Set the list ofMediaType
objects supported by this converter.void
FormHttpMessageConverter. setSupportedMediaTypes(List<MediaType> supportedMediaTypes)
Set the list ofMediaType
objects supported by this converter.参数类型为MediaType的org.springframework.http.converter中的构造器 构造器 说明 AbstractGenericHttpMessageConverter(MediaType supportedMediaType)
Construct anAbstractGenericHttpMessageConverter
with one supported media type.AbstractGenericHttpMessageConverter(MediaType... supportedMediaTypes)
Construct anAbstractGenericHttpMessageConverter
with multiple supported media type.AbstractHttpMessageConverter(Charset defaultCharset, MediaType... supportedMediaTypes)
Construct anAbstractHttpMessageConverter
with a default charset and multiple supported media types.AbstractHttpMessageConverter(MediaType supportedMediaType)
Construct anAbstractHttpMessageConverter
with one supported media type.AbstractHttpMessageConverter(MediaType... supportedMediaTypes)
Construct anAbstractHttpMessageConverter
with multiple supported media types.org.springframework.http.converter.feed中MediaType的使用
参数类型为MediaType的org.springframework.http.converter.feed中的构造器 构造器 说明 AbstractWireFeedHttpMessageConverter(MediaType supportedMediaType)
org.springframework.http.converter.json中MediaType的使用
返回MediaType的org.springframework.http.converter.json中的方法 修饰符和类型 方法 说明 protected MediaType
AbstractJackson2HttpMessageConverter. getDefaultContentType(Object object)
参数类型为MediaType的org.springframework.http.converter.json中的方法 修饰符和类型 方法 说明 boolean
AbstractJackson2HttpMessageConverter. canRead(Class<?> clazz, MediaType mediaType)
boolean
AbstractJackson2HttpMessageConverter. canRead(Type type, Class<?> contextClass, MediaType mediaType)
boolean
AbstractJackson2HttpMessageConverter. canWrite(Class<?> clazz, MediaType mediaType)
protected Charset
AbstractJackson2HttpMessageConverter. getCharset(MediaType contentType)
Determine the charset to use for JSON input.protected Long
AbstractJackson2HttpMessageConverter. getContentLength(Object object, MediaType contentType)
protected JsonEncoding
AbstractJackson2HttpMessageConverter. getJsonEncoding(MediaType contentType)
Determine the JSON encoding to use for the given content type.参数类型为MediaType的org.springframework.http.converter.json中的构造器 构造器 说明 AbstractJackson2HttpMessageConverter(ObjectMapper objectMapper, MediaType supportedMediaType)
AbstractJackson2HttpMessageConverter(ObjectMapper objectMapper, MediaType... supportedMediaTypes)
org.springframework.http.converter.protobuf中MediaType的使用
声明为MediaType的org.springframework.http.converter.protobuf中的字段 修饰符和类型 字段 说明 static MediaType
ProtobufHttpMessageConverter. PROTOBUF
The media-type for protobufapplication/x-protobuf
.返回MediaType的org.springframework.http.converter.protobuf中的方法 修饰符和类型 方法 说明 protected MediaType
ProtobufHttpMessageConverter. getDefaultContentType(com.google.protobuf.Message message)
参数类型为MediaType的org.springframework.http.converter.protobuf中的方法 修饰符和类型 方法 说明 protected boolean
ProtobufHttpMessageConverter. canWrite(MediaType mediaType)
org.springframework.http.converter.xml中MediaType的使用
参数类型为MediaType的org.springframework.http.converter.xml中的方法 修饰符和类型 方法 说明 boolean
Jaxb2CollectionHttpMessageConverter. canRead(Class<?> clazz, MediaType mediaType)
Always returnsfalse
since Jaxb2CollectionHttpMessageConverter required generic type information in order to read a Collection.boolean
Jaxb2CollectionHttpMessageConverter. canRead(Type type, Class<?> contextClass, MediaType mediaType)
Indicates whether the given type can be read by this converter.boolean
Jaxb2RootElementHttpMessageConverter. canRead(Class<?> clazz, MediaType mediaType)
boolean
MarshallingHttpMessageConverter. canRead(Class<?> clazz, MediaType mediaType)
boolean
Jaxb2CollectionHttpMessageConverter. canWrite(Class<?> clazz, MediaType mediaType)
Always returnsfalse
since Jaxb2CollectionHttpMessageConverter does not convert collections to XML.boolean
Jaxb2CollectionHttpMessageConverter. canWrite(Type type, Class<?> clazz, MediaType mediaType)
Always returnsfalse
since Jaxb2CollectionHttpMessageConverter does not convert collections to XML.boolean
Jaxb2RootElementHttpMessageConverter. canWrite(Class<?> clazz, MediaType mediaType)
boolean
MarshallingHttpMessageConverter. canWrite(Class<?> clazz, MediaType mediaType)
protected Long
SourceHttpMessageConverter. getContentLength(T t, MediaType contentType)
void
Jaxb2CollectionHttpMessageConverter. write(T t, Type type, MediaType contentType, HttpOutputMessage outputMessage)
org.springframework.mock.http.server.reactive中MediaType的使用
参数类型为MediaType的org.springframework.mock.http.server.reactive中的方法 修饰符和类型 方法 说明 B
MockServerHttpRequest.BaseBuilder. accept(MediaType... acceptableMediaTypes)
Set the list of acceptable media types, as specified by theAccept
header.MockServerHttpRequest.BodyBuilder
MockServerHttpRequest.BodyBuilder. contentType(MediaType contentType)
Set the media type of the body, as specified by theContent-Type
header.org.springframework.mock.web中MediaType的使用
参数类型为MediaType的org.springframework.mock.web中的方法 修饰符和类型 方法 说明 void
MockServletContext. addMimeType(String fileExtension, MediaType mimeType)
Adds a mime type mapping for use byMockServletContext.getMimeType(String)
.org.springframework.test.web.client.match中MediaType的使用
参数类型为MediaType的org.springframework.test.web.client.match中的方法 修饰符和类型 方法 说明 RequestMatcher
ContentRequestMatchers. contentType(MediaType expectedContentType)
Assert the request content type as aMediaType
.RequestMatcher
ContentRequestMatchers. contentTypeCompatibleWith(MediaType contentType)
Assert the request content type is compatible with the given content type as defined byisCompatibleWith(MediaType)
.org.springframework.test.web.client.response中MediaType的使用
参数类型为MediaType的org.springframework.test.web.client.response中的方法 修饰符和类型 方法 说明 DefaultResponseCreator
DefaultResponseCreator. contentType(MediaType mediaType)
Set theContent-Type
header.static DefaultResponseCreator
MockRestResponseCreators. withSuccess(byte[] body, MediaType contentType)
ResponseCreator
for a 200 response (OK) with byte[] body.static DefaultResponseCreator
MockRestResponseCreators. withSuccess(String body, MediaType contentType)
ResponseCreator
for a 200 response (OK) with String body.static DefaultResponseCreator
MockRestResponseCreators. withSuccess(Resource body, MediaType contentType)
ResponseCreator
for a 200 response (OK) content withResource
-based body.org.springframework.test.web.reactive.server中MediaType的使用
参数类型为MediaType的org.springframework.test.web.reactive.server中的方法 修饰符和类型 方法 说明 S
WebTestClient.RequestHeadersSpec. accept(MediaType... acceptableMediaTypes)
Set the list of acceptable media types, as specified by theAccept
header.WebTestClient.ResponseSpec
HeaderAssertions. contentType(MediaType mediaType)
Expect a "Content-Type" header with the given value.WebTestClient.RequestBodySpec
WebTestClient.RequestBodySpec. contentType(MediaType contentType)
Set the media type of the body, as specified by theContent-Type
header.WebTestClient.ResponseSpec
HeaderAssertions. contentTypeCompatibleWith(MediaType mediaType)
Expect a "Content-Type" header compatible with the given value.org.springframework.test.web.servlet.request中MediaType的使用
参数类型为MediaType的org.springframework.test.web.servlet.request中的方法 修饰符和类型 方法 说明 MockHttpServletRequestBuilder
MockHttpServletRequestBuilder. accept(MediaType... mediaTypes)
Set the 'Accept' header to the given media type(s).MockHttpServletRequestBuilder
MockHttpServletRequestBuilder. contentType(MediaType contentType)
Set the 'Content-Type' header of the request.org.springframework.test.web.servlet.result中MediaType的使用
参数类型为MediaType的org.springframework.test.web.servlet.result中的方法 修饰符和类型 方法 说明 ResultMatcher
ContentResultMatchers. contentType(MediaType contentType)
Assert the ServletResponse content type after parsing it as a MediaType.ResultMatcher
ContentResultMatchers. contentTypeCompatibleWith(MediaType contentType)
Assert the ServletResponse content type is compatible with the given content type as defined byisCompatibleWith(MediaType)
.org.springframework.web中MediaType的使用
返回MediaType的org.springframework.web中的方法 修饰符和类型 方法 说明 MediaType
HttpMediaTypeNotSupportedException. getContentType()
Return the HTTP request content type method that caused the failure.返回变量类型为MediaType的类型的org.springframework.web中的方法 修饰符和类型 方法 说明 List<MediaType>
HttpMediaTypeException. getSupportedMediaTypes()
Return the list of supported media types.参数类型为MediaType的org.springframework.web中的构造器 构造器 说明 HttpMediaTypeNotSupportedException(MediaType contentType, List<MediaType> supportedMediaTypes)
Create a new HttpMediaTypeNotSupportedException.HttpMediaTypeNotSupportedException(MediaType contentType, List<MediaType> supportedMediaTypes, String msg)
Create a new HttpMediaTypeNotSupportedException.类型变量类型为MediaType的org.springframework.web中的构造器参数 构造器 说明 HttpMediaTypeException(String message, List<MediaType> supportedMediaTypes)
Create a new HttpMediaTypeException with a list of supported media types.HttpMediaTypeNotAcceptableException(List<MediaType> supportedMediaTypes)
Create a new HttpMediaTypeNotSupportedException.HttpMediaTypeNotSupportedException(MediaType contentType, List<MediaType> supportedMediaTypes)
Create a new HttpMediaTypeNotSupportedException.HttpMediaTypeNotSupportedException(MediaType contentType, List<MediaType> supportedMediaTypes, String msg)
Create a new HttpMediaTypeNotSupportedException.org.springframework.web.accept中MediaType的使用
类型参数类型为MediaType的org.springframework.web.accept中的字段 修饰符和类型 字段 说明 static List<MediaType>
ContentNegotiationStrategy. MEDIA_TYPE_ALL_LIST
A singleton list withALL
that is returned fromContentNegotiationStrategy.resolveMediaTypes(org.springframework.web.context.request.NativeWebRequest)
when no specific media types are requested.返回MediaType的org.springframework.web.accept中的方法 修饰符和类型 方法 说明 MediaType
PathExtensionContentNegotiationStrategy. getMediaTypeForResource(Resource resource)
已过时。MediaType
ServletPathExtensionContentNegotiationStrategy. getMediaTypeForResource(Resource resource)
已过时。Extends the base classPathExtensionContentNegotiationStrategy.getMediaTypeForResource(org.springframework.core.io.Resource)
with the ability to also look up through the ServletContext.protected MediaType
AbstractMappingContentNegotiationStrategy. handleNoMatch(NativeWebRequest request, String key)
Override to provide handling when a key is not resolved via.protected MediaType
ServletPathExtensionContentNegotiationStrategy. handleNoMatch(NativeWebRequest webRequest, String extension)
已过时。Resolve file extension viaServletContext.getMimeType(String)
and also delegate to base class for a potentialMediaTypeFactory
lookup.protected MediaType
MappingMediaTypeFileExtensionResolver. lookupMediaType(String extension)
Use this method for a reverse lookup from extension to MediaType.返回变量类型为MediaType的类型的org.springframework.web.accept中的方法 修饰符和类型 方法 说明 protected List<MediaType>
MappingMediaTypeFileExtensionResolver. getAllMediaTypes()
List<MediaType>
FixedContentNegotiationStrategy. getContentTypes()
Return the configured list of media types.Map<String,MediaType>
ContentNegotiationManager. getMediaTypeMappings()
Return all registered lookup key to media type mappings by iteratingMediaTypeFileExtensionResolver
s.Map<String,MediaType>
MappingMediaTypeFileExtensionResolver. getMediaTypes()
List<MediaType>
AbstractMappingContentNegotiationStrategy. resolveMediaTypeKey(NativeWebRequest webRequest, String key)
An alternative toAbstractMappingContentNegotiationStrategy.resolveMediaTypes(NativeWebRequest)
that accepts an already extracted key.List<MediaType>
AbstractMappingContentNegotiationStrategy. resolveMediaTypes(NativeWebRequest webRequest)
List<MediaType>
ContentNegotiationManager. resolveMediaTypes(NativeWebRequest request)
List<MediaType>
ContentNegotiationStrategy. resolveMediaTypes(NativeWebRequest webRequest)
Resolve the given request to a list of media types.List<MediaType>
FixedContentNegotiationStrategy. resolveMediaTypes(NativeWebRequest request)
List<MediaType>
HeaderContentNegotiationStrategy. resolveMediaTypes(NativeWebRequest request)
Resolve the given request to a list of media types.参数类型为MediaType的org.springframework.web.accept中的方法 修饰符和类型 方法 说明 protected void
MappingMediaTypeFileExtensionResolver. addMapping(String extension, MediaType mediaType)
Map an extension to a MediaType.void
ContentNegotiationManagerFactoryBean. addMediaType(String key, MediaType mediaType)
An alternative toContentNegotiationManagerFactoryBean.setMediaTypes(java.util.Properties)
for programmatic registrations.protected void
AbstractMappingContentNegotiationStrategy. handleMatch(String key, MediaType mediaType)
Override to provide handling when a key is successfully resolved viaMappingMediaTypeFileExtensionResolver.lookupMediaType(java.lang.String)
.List<String>
ContentNegotiationManager. resolveFileExtensions(MediaType mediaType)
List<String>
MappingMediaTypeFileExtensionResolver. resolveFileExtensions(MediaType mediaType)
List<String>
MediaTypeFileExtensionResolver. resolveFileExtensions(MediaType mediaType)
Resolve the given media type to a list of file extensions.void
ContentNegotiationManagerFactoryBean. setDefaultContentType(MediaType contentType)
Set the default content type to use when no content type is requested.类型变量类型为MediaType的org.springframework.web.accept中的方法参数 修饰符和类型 方法 说明 void
ContentNegotiationManagerFactoryBean. addMediaTypes(Map<String,MediaType> mediaTypes)
An alternative toContentNegotiationManagerFactoryBean.setMediaTypes(java.util.Properties)
for programmatic registrations.void
ContentNegotiationManagerFactoryBean. setDefaultContentTypes(List<MediaType> contentTypes)
Set the default content types to use when no content type is requested.参数类型为MediaType的org.springframework.web.accept中的构造器 构造器 说明 FixedContentNegotiationStrategy(MediaType contentType)
Constructor with a single defaultMediaType
.类型变量类型为MediaType的org.springframework.web.accept中的构造器参数 构造器 说明 AbstractMappingContentNegotiationStrategy(Map<String,MediaType> mediaTypes)
Create an instance with the given map of file extensions and media types.FixedContentNegotiationStrategy(List<MediaType> contentTypes)
Constructor with an ordered List of defaultMediaType
's to return for use in applications that support a variety of content types.MappingMediaTypeFileExtensionResolver(Map<String,MediaType> mediaTypes)
Create an instance with the given map of file extensions and media types.ParameterContentNegotiationStrategy(Map<String,MediaType> mediaTypes)
Create an instance with the given map of file extensions and media types.PathExtensionContentNegotiationStrategy(Map<String,MediaType> mediaTypes)
已过时。Create an instance with the given map of file extensions and media types.ServletPathExtensionContentNegotiationStrategy(ServletContext servletContext, Map<String,MediaType> mediaTypes)
已过时。Create an instance with the given extension-to-MediaType lookup.org.springframework.web.client中MediaType的使用
返回MediaType的org.springframework.web.client中的方法 修饰符和类型 方法 说明 protected MediaType
HttpMessageConverterExtractor. getContentType(ClientHttpResponse response)
Determine the Content-Type of the response based on the "Content-Type" header or otherwise default toAPPLICATION_OCTET_STREAM
.MediaType
UnknownContentTypeException. getContentType()
Return the content type of the response, or "application/octet-stream".参数类型为MediaType的org.springframework.web.client中的构造器 构造器 说明 UnknownContentTypeException(Type targetType, MediaType contentType, int statusCode, String statusText, HttpHeaders responseHeaders, byte[] responseBody)
Construct a new instance of with the given response data.org.springframework.web.reactive.accept中MediaType的使用
类型参数类型为MediaType的org.springframework.web.reactive.accept中的字段 修饰符和类型 字段 说明 static List<MediaType>
RequestedContentTypeResolver. MEDIA_TYPE_ALL_LIST
A singleton list withALL
that is returned fromRequestedContentTypeResolver.resolveMediaTypes(org.springframework.web.server.ServerWebExchange)
when no specific media types are requested.返回变量类型为MediaType的类型的org.springframework.web.reactive.accept中的方法 修饰符和类型 方法 说明 List<MediaType>
FixedContentTypeResolver. getContentTypes()
Return the configured list of media types.List<MediaType>
FixedContentTypeResolver. resolveMediaTypes(ServerWebExchange exchange)
List<MediaType>
HeaderContentTypeResolver. resolveMediaTypes(ServerWebExchange exchange)
List<MediaType>
ParameterContentTypeResolver. resolveMediaTypes(ServerWebExchange exchange)
List<MediaType>
RequestedContentTypeResolver. resolveMediaTypes(ServerWebExchange exchange)
Resolve the given request to a list of requested media types.参数类型为MediaType的org.springframework.web.reactive.accept中的方法 修饰符和类型 方法 说明 void
RequestedContentTypeResolverBuilder. fixedResolver(MediaType... mediaTypes)
Add resolver that returns a fixed set of media types.RequestedContentTypeResolverBuilder.ParameterResolverConfigurer
RequestedContentTypeResolverBuilder.ParameterResolverConfigurer. mediaType(String key, MediaType mediaType)
Configure a mapping between a lookup key (extracted from a query parameter value) and a correspondingMediaType
.类型变量类型为MediaType的org.springframework.web.reactive.accept中的方法参数 修饰符和类型 方法 说明 RequestedContentTypeResolverBuilder.ParameterResolverConfigurer
RequestedContentTypeResolverBuilder.ParameterResolverConfigurer. mediaType(Map<String,MediaType> mediaTypes)
参数类型为MediaType的org.springframework.web.reactive.accept中的构造器 构造器 说明 FixedContentTypeResolver(MediaType mediaType)
Constructor with a single defaultMediaType
.类型变量类型为MediaType的org.springframework.web.reactive.accept中的构造器参数 构造器 说明 FixedContentTypeResolver(List<MediaType> contentTypes)
Constructor with an ordered List of defaultMediaType
's to return for use in applications that support a variety of content types.ParameterContentTypeResolver(Map<String,MediaType> mediaTypes)
org.springframework.web.reactive.function中MediaType的使用
返回MediaType的org.springframework.web.reactive.function中的方法 修饰符和类型 方法 说明 MediaType
UnsupportedMediaTypeException. getContentType()
Return the request Content-Type header if it was parsed successfully, ornull
otherwise.返回变量类型为MediaType的类型的org.springframework.web.reactive.function中的方法 修饰符和类型 方法 说明 List<MediaType>
UnsupportedMediaTypeException. getSupportedMediaTypes()
Return the list of supported content types in cases when the Content-Type header is parsed but not supported, or an empty list otherwise.参数类型为MediaType的org.springframework.web.reactive.function中的构造器 构造器 说明 UnsupportedMediaTypeException(MediaType contentType, List<MediaType> supportedTypes)
Constructor for when the Content-Type can be parsed but is not supported.UnsupportedMediaTypeException(MediaType contentType, List<MediaType> supportedTypes, ResolvableType bodyType)
Constructor for when trying to encode from or decode to a specific Java type.类型变量类型为MediaType的org.springframework.web.reactive.function中的构造器参数 构造器 说明 UnsupportedMediaTypeException(MediaType contentType, List<MediaType> supportedTypes)
Constructor for when the Content-Type can be parsed but is not supported.UnsupportedMediaTypeException(MediaType contentType, List<MediaType> supportedTypes, ResolvableType bodyType)
Constructor for when trying to encode from or decode to a specific Java type.org.springframework.web.reactive.function.client中MediaType的使用
返回变量类型为MediaType的类型的org.springframework.web.reactive.function.client中的方法 修饰符和类型 方法 说明 Optional<MediaType>
ClientResponse.Headers. contentType()
Return the media type of the body, as specified by theContent-Type
header.参数类型为MediaType的org.springframework.web.reactive.function.client中的方法 修饰符和类型 方法 说明 S
WebClient.RequestHeadersSpec. accept(MediaType... acceptableMediaTypes)
Set the list of acceptable media types, as specified by theAccept
header.WebClient.RequestBodySpec
WebClient.RequestBodySpec. contentType(MediaType contentType)
Set the media type of the body, as specified by theContent-Type
header.org.springframework.web.reactive.function.client.support中MediaType的使用
返回变量类型为MediaType的类型的org.springframework.web.reactive.function.client.support中的方法 修饰符和类型 方法 说明 Optional<MediaType>
ClientResponseWrapper.HeadersWrapper. contentType()
org.springframework.web.reactive.function.server中MediaType的使用
返回变量类型为MediaType的类型的org.springframework.web.reactive.function.server中的方法 修饰符和类型 方法 说明 List<MediaType>
ServerRequest.Headers. accept()
Get the list of acceptable media types, as specified by theAccept
header.Optional<MediaType>
ServerRequest.Headers. contentType()
Get the media type of the body, as specified by theContent-Type
header.参数类型为MediaType的org.springframework.web.reactive.function.server中的方法 修饰符和类型 方法 说明 static RequestPredicate
RequestPredicates. accept(MediaType... mediaTypes)
Return aRequestPredicate
that tests if the request's accept header is compatible with any of the given media types.EntityResponse.Builder<T>
EntityResponse.Builder. contentType(MediaType contentType)
Set the media type of the body, as specified by theContent-Type
header.static RequestPredicate
RequestPredicates. contentType(MediaType... mediaTypes)
Return aRequestPredicate
that tests if the request's content type is included by any of the given media types.ServerResponse.BodyBuilder
ServerResponse.BodyBuilder. contentType(MediaType contentType)
Set the media type of the body, as specified by theContent-Type
header.org.springframework.web.reactive.function.server.support中MediaType的使用
返回变量类型为MediaType的类型的org.springframework.web.reactive.function.server.support中的方法 修饰符和类型 方法 说明 List<MediaType>
ServerRequestWrapper.HeadersWrapper. accept()
Optional<MediaType>
ServerRequestWrapper.HeadersWrapper. contentType()
org.springframework.web.reactive.resource中MediaType的使用
参数类型为MediaType的org.springframework.web.reactive.resource中的方法 修饰符和类型 方法 说明 protected void
ResourceWebHandler. setHeaders(ServerWebExchange exchange, Resource resource, MediaType mediaType)
Set headers on the response.org.springframework.web.reactive.result中MediaType的使用
返回MediaType的org.springframework.web.reactive.result中的方法 修饰符和类型 方法 说明 protected MediaType
HandlerResultHandlerSupport. selectMediaType(ServerWebExchange exchange, Supplier<List<MediaType>> producibleTypesSupplier)
Select the best media type for the current request through a content negotiation algorithm.类型变量类型为MediaType的org.springframework.web.reactive.result中的方法参数 修饰符和类型 方法 说明 protected MediaType
HandlerResultHandlerSupport. selectMediaType(ServerWebExchange exchange, Supplier<List<MediaType>> producibleTypesSupplier)
Select the best media type for the current request through a content negotiation algorithm.org.springframework.web.reactive.result.condition中MediaType的使用
返回MediaType的org.springframework.web.reactive.result.condition中的方法 修饰符和类型 方法 说明 MediaType
MediaTypeExpression. getMediaType()
返回变量类型为MediaType的类型的org.springframework.web.reactive.result.condition中的方法 修饰符和类型 方法 说明 Set<MediaType>
ConsumesRequestCondition. getConsumableMediaTypes()
Returns the media types for this condition excluding negated expressions.Set<MediaType>
ProducesRequestCondition. getProducibleMediaTypes()
Return the contained producible media types excluding negated expressions.org.springframework.web.reactive.result.view中MediaType的使用
声明为MediaType的org.springframework.web.reactive.result.view中的字段 修饰符和类型 字段 说明 static MediaType
ViewResolverSupport. DEFAULT_CONTENT_TYPE
The defaultcontent-type
for views.返回变量类型为MediaType的类型的org.springframework.web.reactive.result.view中的方法 修饰符和类型 方法 说明 List<MediaType>
AbstractView. getSupportedMediaTypes()
Get the configured media types supported by this view.List<MediaType>
HttpMessageWriterView. getSupportedMediaTypes()
Return the list of media types this View supports, or an empty list.default List<MediaType>
View. getSupportedMediaTypes()
Return the list of media types this View supports, or an empty list.List<MediaType>
ViewResolverSupport. getSupportedMediaTypes()
Return the configured media types supported by this view.参数类型为MediaType的org.springframework.web.reactive.result.view中的方法 修饰符和类型 方法 说明 reactor.core.publisher.Mono<Void>
AbstractView. render(Map<String,?> model, MediaType contentType, ServerWebExchange exchange)
Prepare the model to render.reactor.core.publisher.Mono<Void>
HttpMessageWriterView. render(Map<String,?> model, MediaType contentType, ServerWebExchange exchange)
reactor.core.publisher.Mono<Void>
View. render(Map<String,?> model, MediaType contentType, ServerWebExchange exchange)
Render the view based on the givenHandlerResult
.protected abstract reactor.core.publisher.Mono<Void>
AbstractView. renderInternal(Map<String,Object> renderAttributes, MediaType contentType, ServerWebExchange exchange)
Subclasses must implement this method to actually render the view.protected reactor.core.publisher.Mono<Void>
RedirectView. renderInternal(Map<String,Object> model, MediaType contentType, ServerWebExchange exchange)
Convert model to request parameters and redirect to the given URL.类型变量类型为MediaType的org.springframework.web.reactive.result.view中的方法参数 修饰符和类型 方法 说明 void
AbstractView. setSupportedMediaTypes(List<MediaType> supportedMediaTypes)
Set the supported media types for this view.void
ViewResolverSupport. setSupportedMediaTypes(List<MediaType> supportedMediaTypes)
Set the supported media types for this view.org.springframework.web.reactive.result.view.freemarker中MediaType的使用
参数类型为MediaType的org.springframework.web.reactive.result.view.freemarker中的方法 修饰符和类型 方法 说明 protected reactor.core.publisher.Mono<Void>
FreeMarkerView. renderInternal(Map<String,Object> renderAttributes, MediaType contentType, ServerWebExchange exchange)
org.springframework.web.reactive.result.view.script中MediaType的使用
参数类型为MediaType的org.springframework.web.reactive.result.view.script中的方法 修饰符和类型 方法 说明 protected reactor.core.publisher.Mono<Void>
ScriptTemplateView. renderInternal(Map<String,Object> model, MediaType contentType, ServerWebExchange exchange)
org.springframework.web.server中MediaType的使用
返回MediaType的org.springframework.web.server中的方法 修饰符和类型 方法 说明 MediaType
UnsupportedMediaTypeStatusException. getContentType()
Return the request Content-Type header if it was parsed successfully, ornull
otherwise.返回变量类型为MediaType的类型的org.springframework.web.server中的方法 修饰符和类型 方法 说明 List<MediaType>
MediaTypeNotSupportedStatusException. getSupportedMediaTypes()
已过时。Return the list of supported content types in cases when the Accept header is parsed but not supported, or an empty list otherwise.List<MediaType>
NotAcceptableStatusException. getSupportedMediaTypes()
Return the list of supported content types in cases when the Accept header is parsed but not supported, or an empty list otherwise.List<MediaType>
UnsupportedMediaTypeStatusException. getSupportedMediaTypes()
Return the list of supported content types in cases when the Content-Type header is parsed but not supported, or an empty list otherwise.参数类型为MediaType的org.springframework.web.server中的构造器 构造器 说明 UnsupportedMediaTypeStatusException(MediaType contentType, List<MediaType> supportedTypes)
Constructor for when the Content-Type can be parsed but is not supported.UnsupportedMediaTypeStatusException(MediaType contentType, List<MediaType> supportedTypes, ResolvableType bodyType)
Constructor for when trying to encode from or decode to a specific Java type.类型变量类型为MediaType的org.springframework.web.server中的构造器参数 构造器 说明 MediaTypeNotSupportedStatusException(List<MediaType> supportedMediaTypes)
已过时。Constructor for when the Content-Type is not supported.NotAcceptableStatusException(List<MediaType> supportedMediaTypes)
Constructor for when the requested Content-Type is not supported.UnsupportedMediaTypeStatusException(MediaType contentType, List<MediaType> supportedTypes)
Constructor for when the Content-Type can be parsed but is not supported.UnsupportedMediaTypeStatusException(MediaType contentType, List<MediaType> supportedTypes, ResolvableType bodyType)
Constructor for when trying to encode from or decode to a specific Java type.org.springframework.web.servlet.config.annotation中MediaType的使用
返回变量类型为MediaType的类型的org.springframework.web.servlet.config.annotation中的方法 修饰符和类型 方法 说明 protected Map<String,MediaType>
WebMvcConfigurationSupport. getDefaultMediaTypes()
参数类型为MediaType的org.springframework.web.servlet.config.annotation中的方法 修饰符和类型 方法 说明 ContentNegotiationConfigurer
ContentNegotiationConfigurer. defaultContentType(MediaType... defaultContentTypes)
Set the default content type(s) to use when no content type is requested in order of priority.ContentNegotiationConfigurer
ContentNegotiationConfigurer. mediaType(String extension, MediaType mediaType)
Add a mapping from a key, extracted from a path extension or a query parameter, to a MediaType.类型变量类型为MediaType的org.springframework.web.servlet.config.annotation中的方法参数 修饰符和类型 方法 说明 ContentNegotiationConfigurer
ContentNegotiationConfigurer. mediaTypes(Map<String,MediaType> mediaTypes)
ContentNegotiationConfigurer
ContentNegotiationConfigurer. replaceMediaTypes(Map<String,MediaType> mediaTypes)
Similar toContentNegotiationConfigurer.mediaType(java.lang.String, org.springframework.http.MediaType)
but for replacing existing mappings.org.springframework.web.servlet.function中MediaType的使用
返回变量类型为MediaType的类型的org.springframework.web.servlet.function中的方法 修饰符和类型 方法 说明 List<MediaType>
ServerRequest.Headers. accept()
Get the list of acceptable media types, as specified by theAccept
header.Optional<MediaType>
ServerRequest.Headers. contentType()
Get the media type of the body, as specified by theContent-Type
header.参数类型为MediaType的org.springframework.web.servlet.function中的方法 修饰符和类型 方法 说明 static RequestPredicate
RequestPredicates. accept(MediaType... mediaTypes)
Return aRequestPredicate
that tests if the request's accept header is compatible with any of the given media types.EntityResponse.Builder<T>
EntityResponse.Builder. contentType(MediaType contentType)
Set the media type of the body, as specified by theContent-Type
header.static RequestPredicate
RequestPredicates. contentType(MediaType... mediaTypes)
Return aRequestPredicate
that tests if the request's content type is included by any of the given media types.ServerResponse.BodyBuilder
ServerResponse.BodyBuilder. contentType(MediaType contentType)
Set the media type of the body, as specified by theContent-Type
header.org.springframework.web.servlet.mvc.condition中MediaType的使用
返回MediaType的org.springframework.web.servlet.mvc.condition中的方法 修饰符和类型 方法 说明 MediaType
MediaTypeExpression. getMediaType()
返回变量类型为MediaType的类型的org.springframework.web.servlet.mvc.condition中的方法 修饰符和类型 方法 说明 Set<MediaType>
ConsumesRequestCondition. getConsumableMediaTypes()
Returns the media types for this condition excluding negated expressions.Set<MediaType>
ProducesRequestCondition. getProducibleMediaTypes()
Return the contained producible media types excluding negated expressions.org.springframework.web.servlet.mvc.method.annotation中MediaType的使用
类型参数类型为MediaType的org.springframework.web.servlet.mvc.method.annotation中的字段 修饰符和类型 字段 说明 protected List<MediaType>
AbstractMessageConverterMethodArgumentResolver. allSupportedMediaTypes
返回MediaType的org.springframework.web.servlet.mvc.method.annotation中的方法 修饰符和类型 方法 说明 MediaType
ResponseBodyEmitter.DataWithMediaType. getMediaType()
返回变量类型为MediaType的类型的org.springframework.web.servlet.mvc.method.annotation中的方法 修饰符和类型 方法 说明 protected List<MediaType>
AbstractMessageConverterMethodProcessor. getProducibleMediaTypes(HttpServletRequest request, Class<?> valueClass)
Returns the media types that can be produced.protected List<MediaType>
AbstractMessageConverterMethodProcessor. getProducibleMediaTypes(HttpServletRequest request, Class<?> valueClass, Type targetType)
Returns the media types that can be produced.参数类型为MediaType的org.springframework.web.servlet.mvc.method.annotation中的方法 修饰符和类型 方法 说明 Object
AbstractMappingJacksonResponseBodyAdvice. beforeBodyWrite(Object body, MethodParameter returnType, MediaType contentType, Class<? extends HttpMessageConverter<?>> converterType, ServerHttpRequest request, ServerHttpResponse response)
T
ResponseBodyAdvice. beforeBodyWrite(T body, MethodParameter returnType, MediaType selectedContentType, Class<? extends HttpMessageConverter<?>> selectedConverterType, ServerHttpRequest request, ServerHttpResponse response)
Invoked after anHttpMessageConverter
is selected and just before its write method is invoked.protected abstract void
AbstractMappingJacksonResponseBodyAdvice. beforeBodyWriteInternal(MappingJacksonValue bodyContainer, MediaType contentType, MethodParameter returnType, ServerHttpRequest request, ServerHttpResponse response)
Invoked only if the converter type isMappingJackson2HttpMessageConverter
.protected void
JsonViewResponseBodyAdvice. beforeBodyWriteInternal(MappingJacksonValue bodyContainer, MediaType contentType, MethodParameter returnType, ServerHttpRequest request, ServerHttpResponse response)
SseEmitter.SseEventBuilder
SseEmitter.SseEventBuilder. data(Object object, MediaType mediaType)
Add an SSE "data" line.void
ResponseBodyEmitter. send(Object object, MediaType mediaType)
Overloaded variant ofResponseBodyEmitter.send(Object)
that also accepts a MediaType hint for how to serialize the given Object.void
SseEmitter. send(Object object, MediaType mediaType)
Send the object formatted as a single SSE "data" line.参数类型为MediaType的org.springframework.web.servlet.mvc.method.annotation中的构造器 构造器 说明 DataWithMediaType(Object data, MediaType mediaType)
org.springframework.web.servlet.resource中MediaType的使用
返回MediaType的org.springframework.web.servlet.resource中的方法 修饰符和类型 方法 说明 protected MediaType
ResourceHttpRequestHandler. getMediaType(HttpServletRequest request, Resource resource)
Determine the media type for the given request and the resource matched to it.返回变量类型为MediaType的类型的org.springframework.web.servlet.resource中的方法 修饰符和类型 方法 说明 Map<String,MediaType>
ResourceHttpRequestHandler. getMediaTypes()
Return theconfigured
media types.参数类型为MediaType的org.springframework.web.servlet.resource中的方法 修饰符和类型 方法 说明 protected void
ResourceHttpRequestHandler. setHeaders(HttpServletResponse response, Resource resource, MediaType mediaType)
Set headers on the given servlet response.类型变量类型为MediaType的org.springframework.web.servlet.resource中的方法参数 修饰符和类型 方法 说明 void
ResourceHttpRequestHandler. setMediaTypes(Map<String,MediaType> mediaTypes)
Add mappings between file extensions, extracted from the filename of a staticResource
, and corresponding media type to set on the response.org.springframework.web.servlet.view中MediaType的使用
返回变量类型为MediaType的类型的org.springframework.web.servlet.view中的方法 修饰符和类型 方法 说明 protected List<MediaType>
ContentNegotiatingViewResolver. getMediaTypes(HttpServletRequest request)
Determines the list ofMediaType
for the givenHttpServletRequest
.org.springframework.web.socket.sockjs.transport.handler中MediaType的使用
返回MediaType的org.springframework.web.socket.sockjs.transport.handler中的方法 修饰符和类型 方法 说明 protected abstract MediaType
AbstractHttpSendingTransportHandler. getContentType()
protected MediaType
EventSourceTransportHandler. getContentType()
protected MediaType
HtmlFileTransportHandler. getContentType()
protected MediaType
XhrPollingTransportHandler. getContentType()
protected MediaType
XhrStreamingTransportHandler. getContentType()