@ -1232,39 +1232,18 @@ to serialize only a subset of the object properties. For example:
@@ -1232,39 +1232,18 @@ to serialize only a subset of the object properties. For example:
[[rest-message-conversion]]
==== HTTP message conversion
==== HTTP Message Converters
[.small]#<<web-reactive.adoc#webflux-codecs,Same in Spring WebFlux>>#
Objects passed to and returned from the methods `getForObject()`, `postForLocation()`,
and `put()` are converted to HTTP requests and from HTTP responses by
`HttpMessageConverters`. The `HttpMessageConverter` interface is shown below to give you
a better feel for its functionality
[source,java,indent=0]
[subs="verbatim,quotes"]
----
public interface HttpMessageConverter<T> {
// Indicate whether the given class and media type can be read by this converter.
@ -110,9 +110,10 @@ of RxJava or other reactive library. See <<webflux-reactive-libraries>> for more
@@ -110,9 +110,10 @@ of RxJava or other reactive library. See <<webflux-reactive-libraries>> for more
[[webflux-programming-models]]
=== Programming models
The `spring-web` module contains the reactive foundation that underlies Spring WebFlux --
HTTP abstractions, Reactive Streams server adapters, reactive codecs, and a
core Web API whose role is comparable to the Servlet API but with non-blocking semantics.
The `spring-web` module contains the reactive foundation that underlies Spring WebFlux
including HTTP abstractions, Reactive Streams <<webflux-httphandler,adapters>> for supported
servers, <<webflux-codecs,codecs>>, and a core <<webflux-web-handler-api>> comparable to
the Servlet API but with non-blocking contracts.
On that foundation Spring WebFlux provides a choice of two programming models:
@ -425,31 +426,34 @@ to have the following detected:
@@ -425,31 +426,34 @@ to have the following detected:
[[webflux-codecs]]
=== Codecs
=== HTTP Message Codecs
[.small]#<<integration.adoc#rest-message-conversion,Same in Spring MVC>>#
The `spring-web` module provides
The `spring-web` module defines the
{api-spring-framework}/http/codec/HttpMessageReader.html[HttpMessageReader] and
@ -2274,7 +2274,8 @@ You could access the part named "meta-data" with a `@RequestParam("meta-data") S
@@ -2274,7 +2274,8 @@ You could access the part named "meta-data" with a `@RequestParam("meta-data") S
metadata` controller method argument. However, you would probably prefer to accept a
strongly typed object initialized from the JSON formatted data in the body of the
request part, very similar to the way `@RequestBody` converts the body of a
non-multipart request to a target object with the help of an `HttpMessageConverter`.
non-multipart request to a target object with the help of an
You can use the `@RequestPart` annotation instead of the `@RequestParam` annotation for
this purpose. It allows you to have the content of a specific multipart passed through
@ -2314,7 +2315,8 @@ be bound to the value of the HTTP request body. For example:
@@ -2314,7 +2315,8 @@ be bound to the value of the HTTP request body. For example:
}
----
You convert the request body to the method argument by using an `HttpMessageConverter`.
You convert the request body to the method argument by using an
`HttpMessageConverter` is responsible for converting from the HTTP request message to an
object and converting from an object to the HTTP response body. The
`RequestMappingHandlerAdapter` supports the `@RequestBody` annotation with the following
@ -2422,8 +2424,7 @@ The above example will result in the text `Hello World` being written to the HTT
@@ -2422,8 +2424,7 @@ The above example will result in the text `Hello World` being written to the HTT
response stream.
As with `@RequestBody`, Spring converts the returned object to a response body by using
an `HttpMessageConverter`. For more information on these converters, see the previous
section and <<integration.adoc#rest-message-conversion,Message Converters>>.
an <<integration.adoc#rest-message-conversion,HttpMessageConverter>>.
[[mvc-ann-responseentity]]
@ -2443,7 +2444,8 @@ also allows setting response headers:
@@ -2443,7 +2444,8 @@ also allows setting response headers:
}
----
As with `@ResponseBody`, Spring uses `HttpMessageConverter` to
As with `@ResponseBody`, Spring uses
<<integration.adoc#rest-message-conversion,HttpMessageConverter>> to
convert from and to the request and response streams. For more information on these
converters, see the previous section and <<integration.adoc#rest-message-conversion,
Message Converters>>.
@ -3353,7 +3355,7 @@ This is a technique related to "Long Polling" that is known as "HTTP Streaming".
@@ -3353,7 +3355,7 @@ This is a technique related to "Long Polling" that is known as "HTTP Streaming".
Spring MVC makes this possible through the `ResponseBodyEmitter` return value
type which can be used to send multiple Objects, instead of one as is normally
the case with `@ResponseBody`, where each Object sent is written to the
response with an `HttpMessageConverter`.
response with an <<integration.adoc#rest-message-conversion,HttpMessageConverter>>.