Spring @ReponseBody @RequestBody with abstract class
问题 Suppose I have three classes. public abstract class Animal {} public class Cat extends Animal {} public class Dog extends Animal {} Can i do something like this? Input: a json which it is Dog or Cat Output: a dog/cat depends on input object type I dont understand why the following code doesnt work. Or should I use two separate methods to handle new dog and cat? @RequestMapping(value = "/animal", method = RequestMethod.POST, produces = "application/json; charset=utf-8") private @ResponseBody