1.传递复杂参数对象需要用Post,另外需要注意,Feign不支持使用GetMapping 和PostMapping
@RequestMapping(value="user/save",method=RequestMethod.POST)
2.在传递的过程中,复杂对象使用@RequestBody进行注解,同时接收端也需要使用@RequestBody这个注解。 博主遇一个坑:
消费端使用了@RequestBody而服务端没有接收@RequestBody,这时参数会接收不完整。
//消费端
@RequestMapping(value="user/save",method=RequestMethod.POST)
public User save(@RequestBody User user);
//服务端
@PostMapping("save")
public User save(@RequestBody User user) {
System.out.println(user);
return UserService.save(user);
}
转载于:https://my.oschina.net/linwl/blog/1834530