本文整理汇总了Java中org.springframework.http.converter.json.MappingJacksonValue.setFilters方法的典型用法代码示例。如果您正苦于以下问题:Java MappingJacksonValue.setFilters方法的具体用法?Java MappingJacksonValue.setFilters怎么用?Java MappingJacksonValue.setFilters使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.springframework.http.converter.json.MappingJacksonValue
的用法示例。
在下文中一共展示了MappingJacksonValue.setFilters方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: findAllTest2
import org.springframework.http.converter.json.MappingJacksonValue; //导入方法依赖的package包/类
@Test
public void findAllTest2() throws Exception {
Auction auction = new Auction();
auction.setRealmId(1);
auction.setItemId(124105);
List<Auction> auctions = auctionService.findAll(auction);
ObjectMapper mapper = new ObjectMapper();
FilterProvider filters = new SimpleFilterProvider().addFilter("auctionFilter",
SimpleBeanPropertyFilter.filterOutAllExcept("owner"));
MappingJacksonValue mappingJacksonValue = new MappingJacksonValue(auctions);
mappingJacksonValue.setFilters(filters);
System.out.println(mappingJacksonValue.getValue());
}
示例2: filterAndWrapModel
import org.springframework.http.converter.json.MappingJacksonValue; //导入方法依赖的package包/类
/**
* Filter and optionally wrap the model in {@link MappingJacksonValue} container.
* @param model the model, as passed on to {@link #renderMergedOutputModel}
* @param request current HTTP request
* @return the wrapped or unwrapped value to be rendered
*/
protected Object filterAndWrapModel(Map<String, Object> model, HttpServletRequest request) {
Object value = filterModel(model);
Class<?> serializationView = (Class<?>) model.get(JsonView.class.getName());
FilterProvider filters = (FilterProvider) model.get(FilterProvider.class.getName());
if (serializationView != null || filters != null) {
MappingJacksonValue container = new MappingJacksonValue(value);
container.setSerializationView(serializationView);
container.setFilters(filters);
value = container;
}
return value;
}
示例3: getSomething2
import org.springframework.http.converter.json.MappingJacksonValue; //导入方法依赖的package包/类
@RequestMapping(value = "/leaguemanager/teams")
public MappingJacksonValue getSomething2(@RequestParam(value = "fields", required = false) String fields) {
Page<Team> r = teamRepository.findAll(new PageRequest(0, 20), 1);
MappingJacksonValue response = new MappingJacksonValue(r);
if (fields != null) {
response.setFilters(processFilterFields(fields, Team.class));
}
return response;
}
示例4: buildResponse
import org.springframework.http.converter.json.MappingJacksonValue; //导入方法依赖的package包/类
protected MappingJacksonValue buildResponse(Object resource, String attributes) {
MappingJacksonValue wrapper = new MappingJacksonValue(resource);
if (!Strings.isNullOrEmpty(attributes)) {
Set<String> attributesSet = extractAttributes(attributes);
FilterProvider filterProvider = new SimpleFilterProvider().addFilter(
"attributeFilter", SimpleBeanPropertyFilter.filterOutAllExcept(attributesSet)
);
wrapper.setFilters(filterProvider);
}
return wrapper;
}
示例5: retrieveSomeBean
import org.springframework.http.converter.json.MappingJacksonValue; //导入方法依赖的package包/类
@GetMapping("/filtering")
public MappingJacksonValue retrieveSomeBean() {
SomeBean someBean = new SomeBean("value1", "value2", "value3");
SimpleBeanPropertyFilter filter = SimpleBeanPropertyFilter.filterOutAllExcept("field1", "field2");
FilterProvider filters = new SimpleFilterProvider().addFilter("SomeBeanFilter", filter);
MappingJacksonValue mapping = new MappingJacksonValue(someBean);
mapping.setFilters(filters);
return mapping;
}
示例6: retrieveListOfSomeBeans
import org.springframework.http.converter.json.MappingJacksonValue; //导入方法依赖的package包/类
@GetMapping("/filtering-list")
public MappingJacksonValue retrieveListOfSomeBeans() {
List<SomeBean> list = Arrays.asList(new SomeBean("value1", "value2", "value3"),
new SomeBean("value12", "value22", "value32"));
SimpleBeanPropertyFilter filter = SimpleBeanPropertyFilter.filterOutAllExcept("field2", "field3");
FilterProvider filters = new SimpleFilterProvider().addFilter("SomeBeanFilter", filter);
MappingJacksonValue mapping = new MappingJacksonValue(list);
mapping.setFilters(filters);
return mapping;
}