gpt4 book ai didi

java - Feign Client : Post a Map in Request Body => feign.FeignException: status 400 reading MAp

转载 作者:行者123 更新时间:2023-11-30 10:07:24 27 4
gpt4 key购买 nike

当我发帖时 Map<String,Object>使用 Feign Client,我收到错误消息:

feign.FeignException: status 400 reading MAp .

代码

//Client side
@Component
@FeignClient(name = ServiceID.TACHE)
@RibbonClient(name = ServiceID.TACHE)
public interface ITacheService extends ITache {
@RequestMapping(value = TACHE_CONTROLLER + "/save", produces = {"application/json; charset=UTF-8"},method = RequestMethod.POST)
@ResponseBody
Map<String, Object> save(@RequestBody Map<String,Object> map);
}

@Controller
@RequestMapping("/task")
public class TaskController {

// Server side
@RequestMapping(value = "/save", produces = {"application/json; charset=UTF-8"},method = RequestMethod.POST)
@ResponseBody
Map<String, Object> save(@RequestBody Map<String, Object> map) throws ParseException { }
}

最佳答案

你真的需要它成为 map 吗?

尝试使用 Hashset 或 HashMap 之类的

//Client side
@Component
@FeignClient(name = ServiceID.TACHE)
@RibbonClient(name = ServiceID.TACHE)
public interface ITacheService extends ITache {
@RequestMapping(value = TACHE_CONTROLLER + "/save", produces = {"application/json; charset=UTF-8"},method = RequestMethod.POST)
@ResponseBody
HashMap<String, Object> save(@RequestBody HashMap<String,Object> map);
}

@Controller
@RequestMapping("/task")
public class TaskController {

// Server side
@RequestMapping(value = "/save", produces = {"application/json; charset=UTF-8"},method = RequestMethod.POST)
@ResponseBody
HashMap<String, Object> save(@RequestBody HashMap<String, Object> map) throws ParseException { }
}

//Client side
@Component
@FeignClient(name = ServiceID.TACHE)
@RibbonClient(name = ServiceID.TACHE)
public interface ITacheService extends ITache {
@RequestMapping(value = TACHE_CONTROLLER + "/save", produces = {"application/json; charset=UTF-8"},method = RequestMethod.POST)
@ResponseBody
HashSet<String, Object> save(@RequestBody HashSet<String,Object> set);
}

@Controller
@RequestMapping("/task")
public class TaskController {

// Server side
@RequestMapping(value = "/save", produces = {"application/json; charset=UTF-8"},method = RequestMethod.POST)
@ResponseBody
HashSet<String, Object> save(@RequestBody HashSet<String, Object> set) throws ParseException { }
}

关于java - Feign Client : Post a Map<String, Object> in Request Body => feign.FeignException: status 400 reading MAp,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54306512/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com