springcloud feignClient 客户端传递spring[] 方法异常解决方案

测试工具为postman,编译软件:idea

 

服务端代码:

重点:调用需post传递

@PostMapping(value = "/forestsAndPid/tree",consumes = "application/json")
public R forestsAndPid( String pid,  String... forestNames){
    List list = sysDeptService.selectListTreeByForestAndPid(Integer.parseInt(pid),forestNames);
    R r = new R(list);
    return r;
}

客户端接口:

注意:参数必须指明参数名称

    @PostMapping(value = "/dept/forestsAndPid/tree",consumes = "application/json")
    public R forestsAndPid(@RequestParam("pid")String pid, @RequestParam("forestNames")String... forestNames);

调用端代码:

    @GetMapping(value = "/forestsPid/tree",consumes = MediaType.APPLICATION_JSON_VALUE)
    public R m221(String pid, String... forestNames) {
        R r =  deptClient.forestsAndPid(pid,forestNames);
        return r;
    }

 

你可能感兴趣的:(springcloud)