Customizing HttpMessageConverters with Spring Boot and Spring MVC - DZone Java
Internally Spring MVC uses a component called a HttpMessageConverter to convert the Http request to an object representation and back.A set of default converters are automatically registered which supports a whole range of different resource representation formats - json, xml for instance.
Now, if there is a need to customize the message converters in some way, Spring Boot makes it simple. As an example consider if the POST method in the sample above needs to be little more flexible and should ignore properties which are not present in the Hotel entity - typically this can be done by configuring the Jackson ObjectMapper, all that needs to be done with Spring Boot is to create a new HttpMessageConverter bean and that would end up overriding all the default message converters, this way:
Read full article from Customizing HttpMessageConverters with Spring Boot and Spring MVC - DZone Java
No comments:
Post a Comment