当我使用Feign Client发布Map<String,Object>
时,出现错误消息:
feign.FeignException:状态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 { }
}
答案 0 :(得分:1)
您真的需要它作为地图吗?
尝试使用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 { }
}