当前位置: 首页>>代码示例>>Java>>正文


Java MappingJacksonValue.setFilters方法代码示例

本文整理汇总了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());
}
 
开发者ID:liufeng0103,项目名称:bnade-web-ssh,代码行数:15,代码来源:AuctionServiceTest.java

示例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;
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:19,代码来源:AbstractJackson2View.java

示例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;
}
 
开发者ID:dentinger,项目名称:LeagueManager,代码行数:12,代码来源:TeamController.java

示例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;
    }
 
开发者ID:osiam,项目名称:osiam,代码行数:13,代码来源:ResourceController.java

示例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;
}
 
开发者ID:in28minutes,项目名称:spring-web-services,代码行数:15,代码来源:FilteringController.java

示例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;
}
 
开发者ID:in28minutes,项目名称:spring-web-services,代码行数:16,代码来源:FilteringController.java


注:本文中的org.springframework.http.converter.json.MappingJacksonValue.setFilters方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。