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

What is the reason why the feign calling service provider returns IPage but the client cannot get the result?

2025-04-01 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

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

This article introduces the knowledge of "the reason why the feign invocation service provider returns IPage but the client cannot get the result". Many people will encounter this dilemma in the operation of actual cases, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

Through the feign call, the service provider returns IPage and the client cannot get the result; the main reason is that jackson needs to serialize the default constructor

@ PostMapping (value = "/ page", consumes = MediaType.APPLICATION_JSON_VALUE)

ResponseModel loadCommentPage (@ RequestBody Comment condition)

Mybatis-plus modification mode

Just change IPage to Page.

The way to modify spring-data is the same. The simplest thing is to implement IPage yourself, or you can recreate the result set by SpringMvcContract.

Several possibilities of feign

1. The API is called directly

2. When the interface is called directly, other modules also need this interface, so other modules need to call it through fegin.

3. It will not be called directly. All APIs will be called through feign.

Based on the above three points, there are the following possibilities

1. Should the service provider return ResponseModel (uniform return value) directly or just the result when using fegin?

1 and 3 can directly return ResponseModel. 2 if the caller returns ResponseModel directly, then the caller needs to judge the code or return it directly to the previous paragraph without any processing. If the result is directly returned, then the API directly called cannot return a unified value. It is recommended to write it as two methods directly.

This is the reason why the feign invocation service provider returned IPage but the client could not get the result. Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!

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

Internet Technology

Wechat

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

12
Report