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

Example Analysis of RequestMappingHandlerAdapter and HttpMessageConverter Assembly in springmvc

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

Share

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

The editor will share with you the example analysis of RequestMappingHandlerAdapter and HttpMessageConverter assembly in springmvc. I hope you will get something after reading this article. Let's discuss it together.

1. DispatcherServlet default assembly RequestMappingHandlerAdapter, and RequestMappingHandlerAdapter default assembly is as follows: HttpMessageConverter

HttpMessageConverter:

2) after adding the jackson jar package, RequestMappingHandlerAdapter

The assembled HttpMessageConverter is as follows:

two。 HttpMessageConverter

1) HttpMessageConverter is a new interface added by Spring3.0, which is responsible for converting request information into an object (type T) and outputting object (type T) as response information.

2) the method defined by the HttpMessageConverter API:

① Boolean canRead (Class clazz,MediaType mediaType): specifies the type of object that the converter can read, that is, whether the converter can convert the request information to an object of type clazz, and specifies that the MIME type is supported (text/html,applaiction/json, etc.)

② Boolean canWrite (Class clazz,MediaType mediaType): specifies whether the converter can write objects of type clazz to the response stream, which supports media types defined in MediaType.

③ List getSupportMediaTypes (): the media type supported by the converter.

④ 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