首页

源码搜藏网

首页 > 开发教程 > java教程 >

springcloudfeign传输List的坑及解决

创建时间:2022-03-16 18:14  

feign传输List的坑

无法直接传输List

错误方法1

@RequestMapping(value = "/stat/merchant/get_merchant_compare_info", method = RequestMethod.POST)
@ResponseBody
MerchantCompareTotalInfo getMerchantCompareInfo(
 @RequestParam(value = "licenseNoList")
 List<String> licenseNoList);

错误:

feign.FeignException: status 500 reading MerchantStatRemoteApi#getMerchantCompareInfo(List); content

错误方法2

@RequestMapping(value = "/stat/merchant/get_merchant_compare_info", method = RequestMethod.POST)
@ResponseBody
MerchantCompareTotalInfo getMerchantCompareInfo(@RequestBody List<String> licenseNoList);

错误:

feign.FeignException: status 500 reading MerchantStatRemoteApi#getMerchantCompareInfo(List); content

错误方法3

@RequestMapping(value = "/stat/merchant/get_merchant_compare_info", method = RequestMethod.POST)
@ResponseBody
MerchantCompareTotalInfo getMerchantCompareInfo(@RequestBody String[] licenseNoList);

服务端的数组是null

正确方法:

@RequestMapping(value = "/stat/merchant/get_merchant_compare_info", method = RequestMethod.POST)
@ResponseBody
MerchantCompareTotalInfo getMerchantCompareInfo(@RequestParam("licenseNoList") String[] licenseNoList);

feign调用传List接不到值

改为传数组 List<Long> 改为 Long[] 再用Arrays.asList()变成集合

以上为个人经验,希望能给大家一个参考,也希望大家多多支持源码搜藏网。

上一篇:java基础理论Stream管道流Map操作示范例子
下一篇:java实现简单图书管理系统

相关内容

热门推荐