dimanche 18 avril 2021

Different class types as RequestBody depending on RequestParam provided in a Spring Boot Controller?

So, I have a controller which takes in a request parameter and a body. The request body can be of various class types depending on the type of parameter. Currently I am using JsonNode for the body which works fine. Looks like this :

@PostMapping() public ResponseEntity<Response> save(@RequestParam("request type") RequestProcess process, @Valid @RequestBody JsonNode requestJson) {

I want to know whether it's possible to provide the body with the class type depending on the param provided. If yes how do I do it? TIA




Aucun commentaire:

Enregistrer un commentaire