spring cloud 项目在feign client 调用时候用到标题错误
服务提供者
@RequestMapping(value="/getMessageqqtest",method= RequestMethod.POST)
public String TestMessage2(Integer num) {
return mrc.getMessage(num+2000);
}
feign client 调用方
@FeignClient(value = "horus-zuul-server")
public interface MessageResultFacade{
@RequestMapping(value = "/chaosclient-service-provider/getMessageqq", method = RequestMethod.POST, produces = "application/json; charset=UTF-8")
String getMessage(Integer num);
}
经过分析 发现是参数没有传过去 参数传到控制器端为null
参考网上思路 要加上requestparam 修改如下
提供者
@RequestMapping(value="/getMessageqqtest1",method= RequestMethod.POST)
public String TestMessage21(@RequestParam Integer num) {
return mrc.getMessage(num+2000);
}
feign 调用方
@FeignClient(value = "horus-zuul-server")
public interface MessageResultFacade{
@RequestMapping(value = "/chaosclient-service-provider/getMessageqq", method = RequestMethod.POST, produces = "application/json; charset=UTF-8")
String getMessage(@RequestParam("num") Integer num);