是否可以使用Jackson @JsonView
和@JsonFilter
批注来修改Spring MVC控制器返回的JSON,同时使用MappingJacksonHttpMessageConverter
和Spring@ResponseBody
和@RequestBody
批注?
public class Product
{
private Integer id;
private Set<ProductDescription> descriptions;
private BigDecimal price;
...
}
public class ProductDescription
{
private Integer id;
private Language language;
private String name;
private String summary;
private String lifeStory;
...
}
当客户机请求Products
个集合时,我想返回每个ProductDescription
的最小版本,也许只是它的ID.然后在后续的调用中,客户机可以使用此ID请求ProductDescription
的完整实例,并且所有属性都存在.
It would be ideal to be able to specify this on the Spring MVC controller methods, as the method invoked defines the context in which client was requesting the data.