'Spring MVC: JSON List in Request Parameters Using PropertyEditorSupport

I'm using Spring Boot 2.5.4, and I have to develop a controller that receives a list of complex objects as requests parameters.

@Value
class Complex {
  String field1;
  String field2;
}

@RestController
class ComplexController {
  @GetMapping(value = "/complexes")
  public List<Complex> getPolicies(@RequestParam @NotEmpty List<Complex> list) {
    return list;
  }
}

I know that I can inject an ObjectMapper in the controller, change the type of the list attribute to String, and use the mapper to deserialize it into a Java object.

What about if I want to extend the PropertyEditorSupport type? AFAIK, the binder binds only on simple types, not generic ones.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source