Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

In-depth Analysis of how to realize HttpMessageConverter message Information Converter

2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

How to realize the in-depth analysis of HttpMessageConverter message converter, in view of this problem, this article introduces the corresponding analysis and solution in detail, hoping to help more partners who want to solve this problem to find a more simple and feasible method.

Preface

HttpMessageConverter, message information converter, converts a request message into a Java object, or a Java object into a response message.

HttpMessageConverter provides two annotations and two types: @ RequestBody,@ResponseBody,RequestEntity,ResponseEntity.

HttpMessageConverter introduction

Org.springframework.http.converter.HttpMessageConverter is a policy interface. The API description is as follows:

Strategy interface that specifies a converter that can convert from and to HTTP requests and responses. Simply put, it is a converter between HTTP request (request) and response (response). There are only five methods for this API. To put it simply, you can get a supported MediaType (such as application/json). When you receive a request, you can determine whether it can be read (canRead), and if you can read it (read); when you return the result, you can determine whether you can write (canWrite), and if you can write (write). You can first make an impression of these methods:

Boolean canRead (Class clazz, MediaType mediaType); boolean canWrite (Class clazz, MediaType mediaType); List getSupportedMediaTypes (); T read (Class)

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report