Spring MVC @RequestBody in an interface instead of a class

People,

This edited code works:

@RequestMapping(method = RequestMethod.GET, produces = "application/json")
public ResponseEntity<List<Member>> findByMemberKeyOrUniqueMemberId(

Note that "Member" is an interface, not a class.

This does not work.

@RequestMapping(method = RequestMethod.POST)
public ResponseEntity<String> save(@RequestBody final List<Member> members) {

Therefore, I can turn members into JSON, but I cannot get JSON into Members. If I changed the save argument from a list to a list of one of the member classes, then it works fine, but it really messed up my code.

How can i fix this?

+1
source share
1 answer

Jackson cannot (this is not feasible) guess which implementation to Memberuse for JSON deserialization.

Jackson @JsonTypeInfo , JSON. , JSON . .

+2

Source: https://habr.com/ru/post/1672970/


All Articles