In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly introduces the failure of the call caused by too many feign parameters, the article is very detailed, has a certain reference value, interested friends must read it!
Call failed error message with too many feign parameters
JSON parse error: Illegal character ((CTRL-CHAR, code 31)): only regular white space (\ r,\ n,\ t) is allowed between tokens...
The above error is reported when calling other services through feign. There is no error when there are few parameters passed in, but if there are more parameters passed in, the hystrix fuse will be used automatically.
Through layer upon layer of investigation
The reason for reporting this error is because
JSON parsing error: illegal character ((CTRL-CHAR, code 31)): only regular spaces (\ r,\ n,\ t) are allowed between tokens.
Json parsing error, I started to think of using an entity class to receive the parameters returned by the opposite side, so report this error, well, I'll use an object to receive it.
But the results show that they still use fuses, and then use map to receive the return parameters, which is the same. Later, I went to Baidu to check that it was necessary to configure feign and cancel the compression.
I tried. It didn't work. Finally, go to Baidu because the transmitted data has been compressed, as long as you add the configuration of feign to remove the compression restrictions. But it was still useless. I had no choice but to consult my colleagues.
Two solutions are given.
The first: reduce the returned data of the callee (this is the method I use, but this method is not a long-term solution)
Second: use the native http to request the opposite api. There are many toolkits on the Internet.
Feign multi-parameter transfer trampling record
It was really a big day. After reading a lot of feign blogs on the Internet, I couldn't find how to deal with it and pass the basic types and entity classes. Write it down here, damn it.
Scene
If there is a paging request now, the front end gives us the following parameters on the consumer side:
PageNum of type int, representing the paging number
PageSize of type int, indicating the number of pieces of data per page
Related parameters of entity class
Then we use thymeleaf, so we need a model to return the paging parameters to the front end
The problem now is
I'm going to pass the pageNum, pageSize and entity classes to the server and ask him to give me the relevant parameters of the paging result.
Solution
1. Consumer controller:
How to receive the parameters here
two。 Corresponding method of consumer feign API:
Add @ RequestParam to two data of type int
Add @ RequestBody to the entity class
3. Server controller:
Same as feign interface method
Add @ RequestParam to two data of type int
Add @ RequestBody to the entity class
Finally, it won't be wrong, xdm.
These are all the contents of the article "what to do if the call fails if there are too many feign parameters". Thank you for reading! Hope to share the content to help you, more related knowledge, welcome to follow the industry information channel!
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.