java - Specify type for @RequestBody when using an abstract class -
i have endpoint have receiving abstract class:
@requestmapping(value = url, method = requestmethod.post) @responsebody public modelmap update(@requestbody someabstractclass form) { ... }
when post error:
could not read json: can not build instance of ..., problem: abstract types can instantiated dditional type info
i understand why i'm getting error, can't figure out specify the additional type information
. ideally specify type of concrete class through 1 of annotations, solution suffice @ point.
i believe uisng jackson json serailizer.
first of create sure have
<context:annotation-config/>
in spring xml conf file.
i used have same issue de-serialization of inherited classes solved annotating
@jsondeserialize(as=child.class) public abstract class abstractparent { ... }
java spring spring-mvc
No comments:
Post a Comment