- Spring Boot 2.0 Cookbook(Second Edition)
- Alex Antonov
- 184字
- 2021-06-24 19:24:41
Configuring custom HttpMessageConverters
While we were building our RESTful web data service, we defined the controllers, repositories, and put some annotations on them; but nowhere did we do any kind of object translation from the Java entity beans to the HTTP data stream output. However, behind the scenes, Spring Boot automatically configured HttpMessageConverters so as to translate our entity beans into a JSON representation written to HTTP response using the Jackson library. When multiple converters are available, the most applicable one gets selected based on the message object class and the requested content type.
The purpose of HttpMessageConverters is to translate various object types into their corresponding HTTP output formats. A converter can either support a range of multiple data types or multiple output formats, or a combination of both. For example, MappingJackson2HttpMessageConverter can translate any Java object into application/json, whereas ProtobufHttpMessageConverter can only operate on instances of com.google.protobuf.Message but can write them to the wire as application/json, application/xml, text/plain, or application/x-protobuf. HttpMessageConverters support not only writing out to the HTTP stream but also converting HTTP requests to appropriate Java objects as well.
- 企業(yè)數(shù)字化創(chuàng)新引擎:企業(yè)級PaaS平臺HZERO
- 數(shù)據(jù)庫技術(shù)與應(yīng)用教程(Access)
- 數(shù)據(jù)之巔:數(shù)據(jù)的本質(zhì)與未來
- InfluxDB原理與實戰(zhàn)
- 文本挖掘:基于R語言的整潔工具
- Libgdx Cross/platform Game Development Cookbook
- 數(shù)據(jù)庫開發(fā)實踐案例
- 基于Apache CXF構(gòu)建SOA應(yīng)用
- Python金融實戰(zhàn)
- Oracle 12c云數(shù)據(jù)庫備份與恢復(fù)技術(shù)
- 從0到1:JavaScript 快速上手
- Hands-On Mathematics for Deep Learning
- 達(dá)夢數(shù)據(jù)庫運維實戰(zhàn)
- 編寫有效用例
- 數(shù)據(jù)庫原理與設(shè)計實驗教程(MySQL版)