I want to select the Json View applied to my data depending on an URL parameter. I am trying to implement this using @JsonView
annotations, and I tried some solutions (1, 2). The thing is that those solutions are basen on the controller action returning a MappingJacksonValue
, but I cannot use that because I am using pagination.
My action:
public ResponseEntity<Page<MyEntity>> findAll(
int viewMode,
Pageable pageable) {
result = service.findAll(pageable);
// Here I would like to apply a Json View to the result set depending
// on the variable viewMode
return new ResponseEntity<Page<MyEntity>>(
/* Resultset with the selected view applied, and paginated */,
HttpStatus.OK
);
}