feign数组传参

服务端:
@RequestMapping("wssp2")
@ResponseBody
public Map<String, String> wssp2(@RequestBody List<User> users) {
    Map<String, String> result = new HashMap<>();
    result.put("code", "200");
    result.put("message", "成功");

    StringBuilder other = new StringBuilder();
    other.append("users size").append(users.size()).append("");
    for (User user : users) {
        other.append(user.getName()).append("");
    }
    result.put("other", other.toString());
    return result;
}
客户端:
@FeignClient(name = "wsClient", url = "${zdry.base.base-api-url}/test")
public interface WsClient {

    @RequestMapping(value = "/wssp", method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_VALUE)
    public String wssp(@RequestBody UserVo user);

    @RequestMapping(value = "/wssp2", method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_VALUE)
    public String wssp2(@RequestBody List<UserVo> users);

}

猜你喜欢

转载自alwaysperfect.iteye.com/blog/2419883