Spring Cloud Feign:在发出POST请求时,Feign不会将参数放入HTTP正文

时间:2016-09-03 10:04:31

标签: spring-cloud-netflix netflix-feign spring-cloud-feign

这是我的Feign界面定义:

@RequestMapping(value = "/group/list", method = RequestMethod.POST)
    List<AdvertGroupVO> list(AdvertGroupVO vo,
                             @RequestParam("page") int page,
                             @RequestParam("size") int size);

虽然这是POST请求,但假设仍将pagesize放入网址而非请求正文:

2016-09-03 17:59:39 [DEBUG] o.a.coyote.http11.InternalNioInputBuffer - Received [POST /group/list?page=1&size=8&groupId=6 HTTP/1.1
Accept: */*
User-Agent: Java/1.8.0_45
Host: 10.236.65.24:8080
Connection: keep-alive

]

我无法弄明白为什么

1 个答案:

答案 0 :(得分:2)

使用@RequestParam注释的参数将被添加到URL查询字符串,而不管HTTP方法如何。只有没有注释的参数才会添加到请求正文中,您必须自定义自己的Feign编码器。