接口的使用
org.springframework.http.converter.HttpMessageConverter
使用HttpMessageConverter的程序包 程序包 说明 org.springframework.http.converter Provides an HttpMessageConverter abstraction to convert between Java objects and HTTP input/output messages.org.springframework.http.converter.cbor Provides an HttpMessageConverter for the CBOR data format.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.smile Provides an HttpMessageConverter for the Smile data format ("binary JSON").org.springframework.http.converter.support Provides a comprehensive HttpMessageConverter variant for form handling.org.springframework.http.converter.xml Provides HttpMessageConverter implementations for handling XML.org.springframework.test.web.servlet.setup Contains built-inMockMvcBuilder
implementations.org.springframework.web.client Core package of the client-side 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.function.support Classes supporting theorg.springframework.web.servlet.function
package.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.http.converter中HttpMessageConverter的使用
org.springframework.http.converter中HttpMessageConverter的子接口 修饰符和类型 接口 说明 interface
GenericHttpMessageConverter<T>
A specialization ofHttpMessageConverter
that can convert an HTTP request into a target object of a specified generic type and a source object of a specified generic type into an HTTP response.实现HttpMessageConverter的org.springframework.http.converter中的类 修饰符和类型 类 说明 class
AbstractGenericHttpMessageConverter<T>
Abstract base class for mostGenericHttpMessageConverter
implementations.class
AbstractHttpMessageConverter<T>
Abstract base class for mostHttpMessageConverter
implementations.class
BufferedImageHttpMessageConverter
Implementation ofHttpMessageConverter
that can read and writeBufferedImages
.class
ByteArrayHttpMessageConverter
Implementation ofHttpMessageConverter
that can read and write byte arrays.class
FormHttpMessageConverter
Implementation ofHttpMessageConverter
to read and write 'normal' HTML forms and also to write (but not read) multipart data (e.g. file uploads).class
ObjectToStringHttpMessageConverter
AnHttpMessageConverter
that usesStringHttpMessageConverter
for reading and writing content and aConversionService
for converting the String content to and from the target object type.class
ResourceHttpMessageConverter
Implementation ofHttpMessageConverter
that can read/writeResources
and supports byte range requests.class
ResourceRegionHttpMessageConverter
Implementation ofHttpMessageConverter
that can write a singleResourceRegion
, or Collections ofResourceRegions
.class
StringHttpMessageConverter
Implementation ofHttpMessageConverter
that can read and write strings.参数类型为HttpMessageConverter的org.springframework.http.converter中的方法 修饰符和类型 方法 说明 void
FormHttpMessageConverter. addPartConverter(HttpMessageConverter<?> partConverter)
Add a message body converter.类型变量类型为HttpMessageConverter的org.springframework.http.converter中的方法参数 修饰符和类型 方法 说明 void
FormHttpMessageConverter. setPartConverters(List<HttpMessageConverter<?>> partConverters)
Set the message body converters to use.org.springframework.http.converter.cbor中HttpMessageConverter的使用
实现HttpMessageConverter的org.springframework.http.converter.cbor中的类 修饰符和类型 类 说明 class
MappingJackson2CborHttpMessageConverter
Implementation ofHttpMessageConverter
that can read and write the CBOR data format using the dedicated Jackson 2.x extension.org.springframework.http.converter.feed中HttpMessageConverter的使用
实现HttpMessageConverter的org.springframework.http.converter.feed中的类 修饰符和类型 类 说明 class
AbstractWireFeedHttpMessageConverter<T extends com.rometools.rome.feed.WireFeed>
Abstract base class for Atom and RSS Feed message converters, using the ROME tools project.class
AtomFeedHttpMessageConverter
Implementation ofHttpMessageConverter
that can read and write Atom feeds.class
RssChannelHttpMessageConverter
Implementation ofHttpMessageConverter
that can read and write RSS feeds.org.springframework.http.converter.json中HttpMessageConverter的使用
实现HttpMessageConverter的org.springframework.http.converter.json中的类 修饰符和类型 类 说明 class
AbstractJackson2HttpMessageConverter
Abstract base class for Jackson based and content type independentHttpMessageConverter
implementations.class
AbstractJsonHttpMessageConverter
Common base class for plain JSON converters, e.g.class
GsonHttpMessageConverter
Implementation ofHttpMessageConverter
that can read and write JSON using the Google Gson library.class
JsonbHttpMessageConverter
Implementation ofHttpMessageConverter
that can read and write JSON using the JSON Binding API.class
MappingJackson2HttpMessageConverter
Implementation ofHttpMessageConverter
that can read and write JSON using Jackson 2.x'sObjectMapper
.org.springframework.http.converter.protobuf中HttpMessageConverter的使用
实现HttpMessageConverter的org.springframework.http.converter.protobuf中的类 修饰符和类型 类 说明 class
ProtobufHttpMessageConverter
AnHttpMessageConverter
that reads and writescom.google.protobuf.Messages
using Google Protocol Buffers.class
ProtobufJsonFormatHttpMessageConverter
Subclass ofProtobufHttpMessageConverter
which enforces the use of Protobuf 3 and its official library"com.google.protobuf:protobuf-java-util"
for JSON processing.org.springframework.http.converter.smile中HttpMessageConverter的使用
实现HttpMessageConverter的org.springframework.http.converter.smile中的类 修饰符和类型 类 说明 class
MappingJackson2SmileHttpMessageConverter
Implementation ofHttpMessageConverter
that can read and write Smile data format ("binary JSON") using the dedicated Jackson 2.x extension.org.springframework.http.converter.support中HttpMessageConverter的使用
实现HttpMessageConverter的org.springframework.http.converter.support中的类 修饰符和类型 类 说明 class
AllEncompassingFormHttpMessageConverter
Extension ofFormHttpMessageConverter
, adding support for XML and JSON-based parts.org.springframework.http.converter.xml中HttpMessageConverter的使用
org.springframework.test.web.servlet.setup中HttpMessageConverter的使用
参数类型为HttpMessageConverter的org.springframework.test.web.servlet.setup中的方法 修饰符和类型 方法 说明 StandaloneMockMvcBuilder
StandaloneMockMvcBuilder. setMessageConverters(HttpMessageConverter<?>... messageConverters)
Set the message converters to use in argument resolvers and in return value handlers, which support reading and/or writing to the body of the request and response.org.springframework.web.client中HttpMessageConverter的使用
返回变量类型为HttpMessageConverter的类型的org.springframework.web.client中的方法 修饰符和类型 方法 说明 List<HttpMessageConverter<?>>
AsyncRestTemplate. getMessageConverters()
已过时。Return the message body converters.List<HttpMessageConverter<?>>
RestTemplate. getMessageConverters()
Return the list of message body converters.类型变量类型为HttpMessageConverter的org.springframework.web.client中的方法参数 修饰符和类型 方法 说明 void
AsyncRestTemplate. setMessageConverters(List<HttpMessageConverter<?>> messageConverters)
已过时。Set the message body converters to use.void
ExtractingResponseErrorHandler. setMessageConverters(List<HttpMessageConverter<?>> messageConverters)
Set the message converters to use by this extractor.void
RestTemplate. setMessageConverters(List<HttpMessageConverter<?>> messageConverters)
Set the message body converters to use.类型变量类型为HttpMessageConverter的org.springframework.web.client中的构造器参数 构造器 说明 ExtractingResponseErrorHandler(List<HttpMessageConverter<?>> messageConverters)
Create a newExtractingResponseErrorHandler
with the givenHttpMessageConverter
instances.HttpMessageConverterExtractor(Class<T> responseType, List<HttpMessageConverter<?>> messageConverters)
Create a new instance of theHttpMessageConverterExtractor
with the given response type and message converters.HttpMessageConverterExtractor(Type responseType, List<HttpMessageConverter<?>> messageConverters)
Creates a new instance of theHttpMessageConverterExtractor
with the given response type and message converters.RestTemplate(List<HttpMessageConverter<?>> messageConverters)
Create a new instance of theRestTemplate
using the given list ofHttpMessageConverter
to use.org.springframework.web.servlet.config.annotation中HttpMessageConverter的使用
返回变量类型为HttpMessageConverter的类型的org.springframework.web.servlet.config.annotation中的方法 修饰符和类型 方法 说明 protected List<HttpMessageConverter<?>>
WebMvcConfigurationSupport. getMessageConverters()
Provides access to the sharedHttpMessageConverters
used by theRequestMappingHandlerAdapter
and theExceptionHandlerExceptionResolver
.类型变量类型为HttpMessageConverter的org.springframework.web.servlet.config.annotation中的方法参数 修饰符和类型 方法 说明 protected void
WebMvcConfigurationSupport. addDefaultHttpMessageConverters(List<HttpMessageConverter<?>> messageConverters)
Adds a set of default HttpMessageConverter instances to the given list.protected void
DelegatingWebMvcConfiguration. configureMessageConverters(List<HttpMessageConverter<?>> converters)
protected void
WebMvcConfigurationSupport. configureMessageConverters(List<HttpMessageConverter<?>> converters)
Override this method to add customHttpMessageConverters
to use with theRequestMappingHandlerAdapter
and theExceptionHandlerExceptionResolver
.default void
WebMvcConfigurer. configureMessageConverters(List<HttpMessageConverter<?>> converters)
Configure theHttpMessageConverters
to use for reading or writing to the body of the request or response.void
WebMvcConfigurerAdapter. configureMessageConverters(List<HttpMessageConverter<?>> converters)
已过时。Configure theHttpMessageConverters
to use for reading or writing to the body of the request or response.protected void
DelegatingWebMvcConfiguration. extendMessageConverters(List<HttpMessageConverter<?>> converters)
protected void
WebMvcConfigurationSupport. extendMessageConverters(List<HttpMessageConverter<?>> converters)
Override this method to extend or modify the list of converters after it has been configured.default void
WebMvcConfigurer. extendMessageConverters(List<HttpMessageConverter<?>> converters)
A hook for extending or modifying the list of converters after it has been configured.void
WebMvcConfigurerAdapter. extendMessageConverters(List<HttpMessageConverter<?>> converters)
已过时。A hook for extending or modifying the list of converters after it has been configured.org.springframework.web.servlet.function中HttpMessageConverter的使用
返回变量类型为HttpMessageConverter的类型的org.springframework.web.servlet.function中的方法 修饰符和类型 方法 说明 List<HttpMessageConverter<?>>
ServerRequest. messageConverters()
Get the readers used to convert the body of this request.List<HttpMessageConverter<?>>
ServerResponse.Context. messageConverters()
Return theHttpMessageConverters
to be used for response body conversion.类型变量类型为HttpMessageConverter的org.springframework.web.servlet.function中的方法参数 修饰符和类型 方法 说明 static ServerRequest
ServerRequest. create(HttpServletRequest servletRequest, List<HttpMessageConverter<?>> messageReaders)
Create a newServerRequest
based on the givenHttpServletRequest
and message converters.org.springframework.web.servlet.function.support中HttpMessageConverter的使用
类型变量类型为HttpMessageConverter的org.springframework.web.servlet.function.support中的方法参数 修饰符和类型 方法 说明 void
RouterFunctionMapping. setMessageConverters(List<HttpMessageConverter<?>> messageConverters)
org.springframework.web.servlet.mvc.method.annotation中HttpMessageConverter的使用
类型参数类型为HttpMessageConverter的org.springframework.web.servlet.mvc.method.annotation中的字段 修饰符和类型 字段 说明 protected List<HttpMessageConverter<?>>
AbstractMessageConverterMethodArgumentResolver. messageConverters
返回变量类型为HttpMessageConverter的类型的org.springframework.web.servlet.mvc.method.annotation中的方法 修饰符和类型 方法 说明 List<HttpMessageConverter<?>>
ExceptionHandlerExceptionResolver. getMessageConverters()
Return the configured message body converters.List<HttpMessageConverter<?>>
RequestMappingHandlerAdapter. getMessageConverters()
Return the configured message body converters.类型变量类型为HttpMessageConverter的org.springframework.web.servlet.mvc.method.annotation中的方法参数 修饰符和类型 方法 说明 Object
RequestBodyAdvice. afterBodyRead(Object body, HttpInputMessage inputMessage, MethodParameter parameter, Type targetType, Class<? extends HttpMessageConverter<?>> converterType)
Invoked third (and last) after the request body is converted to an Object.Object
RequestBodyAdviceAdapter. afterBodyRead(Object body, HttpInputMessage inputMessage, MethodParameter parameter, Type targetType, Class<? extends HttpMessageConverter<?>> converterType)
The default implementation returns the body that was passed in.HttpInputMessage
JsonViewRequestBodyAdvice. beforeBodyRead(HttpInputMessage inputMessage, MethodParameter methodParameter, Type targetType, Class<? extends HttpMessageConverter<?>> selectedConverterType)
HttpInputMessage
RequestBodyAdvice. beforeBodyRead(HttpInputMessage inputMessage, MethodParameter parameter, Type targetType, Class<? extends HttpMessageConverter<?>> converterType)
Invoked second before the request body is read and converted.HttpInputMessage
RequestBodyAdviceAdapter. beforeBodyRead(HttpInputMessage inputMessage, MethodParameter parameter, Type targetType, Class<? extends HttpMessageConverter<?>> converterType)
The default implementation returns the InputMessage that was passed in.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.Object
RequestBodyAdvice. handleEmptyBody(Object body, HttpInputMessage inputMessage, MethodParameter parameter, Type targetType, Class<? extends HttpMessageConverter<?>> converterType)
Invoked second (and last) if the body is empty.Object
RequestBodyAdviceAdapter. handleEmptyBody(Object body, HttpInputMessage inputMessage, MethodParameter parameter, Type targetType, Class<? extends HttpMessageConverter<?>> converterType)
The default implementation returns the body that was passed in.void
ExceptionHandlerExceptionResolver. setMessageConverters(List<HttpMessageConverter<?>> messageConverters)
Set the message body converters to use.void
RequestMappingHandlerAdapter. setMessageConverters(List<HttpMessageConverter<?>> messageConverters)
Provide the converters to use in argument resolvers and return value handlers that support reading and/or writing to the body of the request and response.boolean
AbstractMappingJacksonResponseBodyAdvice. supports(MethodParameter returnType, Class<? extends HttpMessageConverter<?>> converterType)
boolean
JsonViewRequestBodyAdvice. supports(MethodParameter methodParameter, Type targetType, Class<? extends HttpMessageConverter<?>> converterType)
boolean
JsonViewResponseBodyAdvice. supports(MethodParameter returnType, Class<? extends HttpMessageConverter<?>> converterType)
boolean
RequestBodyAdvice. supports(MethodParameter methodParameter, Type targetType, Class<? extends HttpMessageConverter<?>> converterType)
Invoked first to determine if this interceptor applies.boolean
ResponseBodyAdvice. supports(MethodParameter returnType, Class<? extends HttpMessageConverter<?>> converterType)
Whether this component supports the given controller method return type and the selectedHttpMessageConverter
type.类型变量类型为HttpMessageConverter的org.springframework.web.servlet.mvc.method.annotation中的构造器参数 构造器 说明 AbstractMessageConverterMethodArgumentResolver(List<HttpMessageConverter<?>> converters)
Basic constructor with converters only.AbstractMessageConverterMethodArgumentResolver(List<HttpMessageConverter<?>> converters, List<Object> requestResponseBodyAdvice)
Constructor with converters andRequest~
andResponseBodyAdvice
.AbstractMessageConverterMethodProcessor(List<HttpMessageConverter<?>> converters)
Constructor with list of converters only.AbstractMessageConverterMethodProcessor(List<HttpMessageConverter<?>> converters, ContentNegotiationManager contentNegotiationManager)
Constructor with list of converters and ContentNegotiationManager.AbstractMessageConverterMethodProcessor(List<HttpMessageConverter<?>> converters, ContentNegotiationManager manager, List<Object> requestResponseBodyAdvice)
Constructor with list of converters and ContentNegotiationManager as well as request/response body advice instances.HttpEntityMethodProcessor(List<HttpMessageConverter<?>> converters)
Basic constructor with converters only.HttpEntityMethodProcessor(List<HttpMessageConverter<?>> converters, List<Object> requestResponseBodyAdvice)
Complete constructor for resolvingHttpEntity
method arguments.HttpEntityMethodProcessor(List<HttpMessageConverter<?>> converters, ContentNegotiationManager manager)
Basic constructor with converters andContentNegotiationManager
.HttpEntityMethodProcessor(List<HttpMessageConverter<?>> converters, ContentNegotiationManager manager, List<Object> requestResponseBodyAdvice)
Complete constructor for resolvingHttpEntity
and handlingResponseEntity
.RequestPartMethodArgumentResolver(List<HttpMessageConverter<?>> messageConverters)
Basic constructor with converters only.RequestPartMethodArgumentResolver(List<HttpMessageConverter<?>> messageConverters, List<Object> requestResponseBodyAdvice)
Constructor with converters andRequest~
andResponseBodyAdvice
.RequestResponseBodyMethodProcessor(List<HttpMessageConverter<?>> converters)
Basic constructor with converters only.RequestResponseBodyMethodProcessor(List<HttpMessageConverter<?>> converters, List<Object> requestResponseBodyAdvice)
Complete constructor for resolving@RequestBody
method arguments.RequestResponseBodyMethodProcessor(List<HttpMessageConverter<?>> converters, ContentNegotiationManager manager)
Basic constructor with converters andContentNegotiationManager
.RequestResponseBodyMethodProcessor(List<HttpMessageConverter<?>> converters, ContentNegotiationManager manager, List<Object> requestResponseBodyAdvice)
Complete constructor for resolving@RequestBody
and handling@ResponseBody
.ResponseBodyEmitterReturnValueHandler(List<HttpMessageConverter<?>> messageConverters)
Simple constructor with reactive type support based on a default instance ofReactiveAdapterRegistry
,SyncTaskExecutor
, andContentNegotiationManager
with an Accept header strategy.ResponseBodyEmitterReturnValueHandler(List<HttpMessageConverter<?>> messageConverters, ReactiveAdapterRegistry registry, TaskExecutor executor, ContentNegotiationManager manager)
Complete constructor with pluggable "reactive" type support.