在公司的一个spring cloud 项目中,用feign client 调用服务遇到一个404问题

原服务提供者:
@RequestMapping(value="/index",method= RequestMethod.GET)
public String index(String date) {
return uv.index(date);
}
原feign client 调用方:
@FeignClient(value = "horus-zuul-server")
public interface UvInfo{
@RequestMapping(value = "/uv/getUvCount", method = RequestMethod.GET, produces = "application/json; charset=UTF-8")
String index(String date);
经过分析 发现是参数没有传过去 参数传到控制器端为null
解决方法:
参考网上思路 需要加上requestparam修饰,具体修改如下:
提供者:
@RequestMapping(value="/index",method= RequestMethod.GET)
public String index(@RequestParam String date) {
return uv.index(date);
}
feign 调用方:
@FeignClient(value = "horus-zuul-server")
public interface UvInfo{
@RequestMapping(value = "/uv/index", method = RequestMethod.GET, produces = "application/json; charset=UTF-8")
String index(@RequestParam("date") String date);
完
网友评论