Spring Boot Request Body | Rest Controller | Rest API

Описание к видео Spring Boot Request Body | Rest Controller | Rest API

Hi guys,

In this lesson, we will talk about the spring request body.

Spring provides a RequestBody annotation for rest api.

the @RequestBody annotation maps the HttpRequest body to a transfer or domain object, enabling automatic deserialization of the inbound HttpRequest body onto a Java object.

If a method parameter is annotated with @RequestBody, Spring will bind the incoming HTTP request body to that parameter. While doing that, Spring will use HTTP Message converters to convert the HTTP request body into domain object.

Spring provides many default HttpMessageConverters, which will be used for conversion, depending on the presence of a certain library in project classpath.
Of course, we can use different content types in spring like json, xml etc.
For example, if the Content-Type in request Header is application/json , that means the POST body contains json, and if Jackson library is found in your classpath, Spring will delegate the conversion to JacksonHttpMessageConverter [for json].
We will see the details of it on our project.
That’s all for the beginning.
Thank you.

Комментарии

Информация по комментариям в разработке