1. 问题
-
使用Feign进行Get方法调用
传递简单参数,成功
//路径 : http://localhost:10010/findUser?uid=1 @GetMapping("/findStudentBySid") public BaseResult findStudentBySid(@RequestParam("uid") string uid);
报错
原因 : feign使用get进行调用时,如果遇到复杂参数会自动转化成Post请求
//路径 : http://localhost:10010/findUser?uid=1$username=jack&password=1234 @GetMapping("/findStudentBySid") public BaseResult findStudentBySid(User user);
2. 解决方案
2.1 使用SpringQueryMap 注解标记对象参数(推荐)
//路径 : http://localhost:10010/findUser?uid=1$username=jack&password=1234
@GetMapping("/findStudentBySid")
public BaseResult findStudentBySid(@SpringQueryMap User user);
2.2 改为Post请求接口(不推荐)
//路径 : http://localhost:10010/findUser
@PostMapping("/findStudentBySid")
public BaseResult findStudentBySid(@RequestBody User user);