假装客户端:在请求正文中发布映射<字符串,对象>=>假装。假装异常:状态 400 读取 MAp



当我使用Feign客户端发布Map<String,Object>时,我收到错误消息:

装。假装异常:状态 400 读取 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 { }
}

你真的需要它成为地图吗?

尝试使用哈希集或哈希图,例如

//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 { }
}

相关内容

  • 没有找到相关文章

最新更新