【学习笔记】Fegin的GET请求如何传递对象
近期做项目发现使用Fegin的GET请求时,如果使用了对象进行传输,会被当做POST请求处理。
解决方法如下:
1.接口使用@ModelAttribute注解。
@GetMapping("/getTest")
public ResponseData getTest(@ModelAttribute TestModel model) {
return ResponseData.success(biz.getTest(model));
}
2.Fegin调用方需要使用@SpringQueryMap注解进行修饰。
@GetMapping("/fegin/getTest")
ResponseData getTest(@SpringQueryMap TestModel model);
所以再使用Fegin进行Get请求并且传参时,需要使用@SpringQueryMap 注解将对象参数做处理。
转载声明:本文为13762983263@139.com的原创文章,已获得允许转载,原文地址:https://www.byteblogs.com/article/935