1. 问题描述:早期controller有一个由前端直接调用的获取商品详情的接口getGoodsInfo(ReqGoodsInfo req), Get请求方式;
后来想要在业务服务由后台对商品详情页的几个接口整合成一个,那么前端直接只调用一次即可。选择了feign昨晚跨服务调用的调用框架。那么原先的getGoodsInfo接口就要提供一个可供调用的client端如下
@RequestMapping( method = RequestMethod.GET, value = "/goods/***/goodsInfo", produces = MediaType.APPLICATION_JSON_UTF8_VALUE) ResultInfo<RespUsersideGoodsInfo> getUsersideGoodsInfo(@RequestParam("req") ReqGoodsInfo req);
很遗憾,feign并不支持get请求参数对象,feign在底层会直接将get的请求方式转为post请求。
private synchronized OutputStream getOutputStream0() throws IOException {
try {
if (!this.doOutput) {
throw new ProtocolException("cannot write to a URLConnection if doOutput=false - call setDoOutput(true)");
} else {
if (this.method.equals("GET")) {
this.method = "POST";
}
}
}
}<