ITeye博客

feign数组传参

alwaysperfect · 2018-04-24 15:24 · Spring · 行业应用 · Markdown

服务端:
@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);

}

评论(0)

暂无评论。

评论功能维护中,当前仅展示历史评论。