有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

java在使用抽象类时为@RequestBody指定类型

我有一个接收抽象类的端点:

@RequestMapping(value = URL, method = RequestMethod.POST)
@ResponseBody
public ModelMap update(@RequestBody SomeAbstractClass form) {
      ...
}

当我发布到它时,我得到了一个错误:

Could not read JSON: Can not construct instance of ..., 
problem: abstract types can only be instantiated with dditional type information

我理解为什么会出现这个错误,但我不知道应该在哪里指定the additional type information。理想情况下,我可以通过其中一个注释指定具体类的类型,但此时任何解决方案都已足够


共 (0) 个答案