SpringCloud Feign报错:Method has too many Body parameters

feign多参数问题

GET请求

错误写法

@RequestMapping(value="/test", method=RequestMethod.GET)  
void test(final String name,  final int age);  

正确写法

@RequestMapping(value="/test", method=RequestMethod.GET)  
void test(@RequestParam("name") final String name,@RequestParam("age")  final int age);  

POST请求

错误写法

public int save(@RequestBody final Person p, @RequestBody final UserModel user);

feign中你可以有多个@RequestParam,但只能有不超过一个@RequestBody。

正确写法

public int save(@RequestBody final Person p,@RequestParam("userId") String userId,@RequestParam("userTel") String userTel);

 

posted @ 2021-06-28 14:00  陈彦斌  阅读(343)  评论(0)    收藏  举报