【发布时间】:2018-04-18 09:12:18
【问题描述】:
我想根据 URL 参数选择应用于我的数据的 Json 视图。我正在尝试使用@JsonView 注释来实现这一点,并且我尝试了一些解决方案(1、2)。问题是这些解决方案基于返回 MappingJacksonValue 的控制器操作,但我不能使用它,因为我正在使用分页。
我的行动:
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
);
}
【问题讨论】:
标签: spring spring-mvc spring-boot