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


Java ContentNegotiatingViewResolver.setContentNegotiationManager方法代码示例

本文整理汇总了Java中org.springframework.web.servlet.view.ContentNegotiatingViewResolver.setContentNegotiationManager方法的典型用法代码示例。如果您正苦于以下问题:Java ContentNegotiatingViewResolver.setContentNegotiationManager方法的具体用法?Java ContentNegotiatingViewResolver.setContentNegotiationManager怎么用?Java ContentNegotiatingViewResolver.setContentNegotiationManager使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.springframework.web.servlet.view.ContentNegotiatingViewResolver的用法示例。


在下文中一共展示了ContentNegotiatingViewResolver.setContentNegotiationManager方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: contentNegotiatingViewResolver

import org.springframework.web.servlet.view.ContentNegotiatingViewResolver; //导入方法依赖的package包/类
@Bean
public ContentNegotiatingViewResolver contentNegotiatingViewResolver() {
    List<View> defaultViews = new ArrayList<>(2);
    defaultViews.add(jsonCatnapSpringView());
    defaultViews.add(jsonpCatnapSpringView());

    List<CatnapWrappingView> catnapViews = new ArrayList<>(2);
    catnapViews.add(jsonCatnapSpringView());
    catnapViews.add(jsonpCatnapSpringView());

    CatnapViewResolver catnapViewResolver = new CatnapViewResolver();
    catnapViewResolver.setViews(catnapViews);

    List<ViewResolver> viewResolvers = new ArrayList<>(1);
    viewResolvers.add(catnapViewResolver);

    ContentNegotiatingViewResolver cnvr = new ContentNegotiatingViewResolver();
    cnvr.setContentNegotiationManager(mvcContentNegotiationManager());
    cnvr.setOrder(1);
    cnvr.setDefaultViews(defaultViews);
    cnvr.setViewResolvers(viewResolvers);

    return cnvr;
}
 
开发者ID:gregwhitaker,项目名称:catnap,代码行数:25,代码来源:DelegatingCatnapWebMvcConfiguration.java

示例2: contentNegotiatingViewResolver

import org.springframework.web.servlet.view.ContentNegotiatingViewResolver; //导入方法依赖的package包/类
@Bean
public ViewResolver contentNegotiatingViewResolver(
        ContentNegotiationManager manager) {

    List< ViewResolver > resolvers = new ArrayList<ViewResolver>();

    UrlBasedViewResolver viewResolver = new UrlBasedViewResolver();
    viewResolver.setViewClass(TilesView.class);
    resolvers.add(viewResolver);

    JsonViewResolver r2 = new JsonViewResolver();
    resolvers.add(r2);

    ContentNegotiatingViewResolver resolver = new ContentNegotiatingViewResolver();
    resolver.setViewResolvers(resolvers);
    resolver.setContentNegotiationManager(manager);
    return resolver;

}
 
开发者ID:gill3s,项目名称:opentipbot,代码行数:20,代码来源:WebAppContext.java

示例3: contentNegotiatingViewResolver

import org.springframework.web.servlet.view.ContentNegotiatingViewResolver; //导入方法依赖的package包/类
@Bean
public ViewResolver contentNegotiatingViewResolver(ContentNegotiationManager manager) {
	ContentNegotiatingViewResolver resolver = new ContentNegotiatingViewResolver();
	resolver.setContentNegotiationManager(manager);

	// Define all possible view resolvers
	List<ViewResolver> resolvers = new ArrayList<ViewResolver>();

	resolvers.add(excelViewResolver());
	
	resolver.setViewResolvers(resolvers);
	return resolver;
}
 
开发者ID:mustafamym,项目名称:FeedbackCollectionAndMgmtSystem,代码行数:14,代码来源:AppConfig.java

示例4: cnViewResolver

import org.springframework.web.servlet.view.ContentNegotiatingViewResolver; //导入方法依赖的package包/类
/**
 * Bean to configure view resolver
 *
 * @param cnm the content negotion manager
 * @return the view resolver
 */
@Bean
public ViewResolver cnViewResolver(final ContentNegotiationManager cnm) {
    final ContentNegotiatingViewResolver cnvr =
            new ContentNegotiatingViewResolver();
    cnvr.setContentNegotiationManager(cnm);
    return cnvr;
}
 
开发者ID:mhaddon,项目名称:Sound.je,代码行数:14,代码来源:TemplateConfig.java

示例5: contentNegotiatingViewResolver

import org.springframework.web.servlet.view.ContentNegotiatingViewResolver; //导入方法依赖的package包/类
@Bean
public ViewResolver contentNegotiatingViewResolver(
        ContentNegotiationManager manager) { // Esse método determina os possiveis formatos de retorno da viewResolver
    List<ViewResolver> resolvers = new ArrayList<ViewResolver>();

    resolvers.add(internalResourceViewResolver());
    resolvers.add(new JsonViewResolver());
    resolvers.add(getMarshallingXmlViewResolver());

    ContentNegotiatingViewResolver resolver
            = new ContentNegotiatingViewResolver();
    resolver.setViewResolvers(resolvers);
    resolver.setContentNegotiationManager(manager);
    return resolver;
}
 
开发者ID:nailtonvieira,项目名称:pswot-cloud-java-spring-webapp,代码行数:16,代码来源:AppWebConfiguration.java

示例6: testContentNegotiation

import org.springframework.web.servlet.view.ContentNegotiatingViewResolver; //导入方法依赖的package包/类
@Test
public void testContentNegotiation() throws Exception {

	Jaxb2Marshaller marshaller = new Jaxb2Marshaller();
	marshaller.setClassesToBeBound(Person.class);

	List<View> viewList = new ArrayList<View>();
	viewList.add(new MappingJackson2JsonView());
	viewList.add(new MarshallingView(marshaller));

	ContentNegotiationManager manager = new ContentNegotiationManager(
			new HeaderContentNegotiationStrategy(), new FixedContentNegotiationStrategy(MediaType.TEXT_HTML));

	ContentNegotiatingViewResolver cnViewResolver = new ContentNegotiatingViewResolver();
	cnViewResolver.setDefaultViews(viewList);
	cnViewResolver.setContentNegotiationManager(manager);
	cnViewResolver.afterPropertiesSet();

	MockMvc mockMvc =
		standaloneSetup(new PersonController())
			.setViewResolvers(cnViewResolver, new InternalResourceViewResolver())
			.build();

	mockMvc.perform(get("/person/Corea"))
		.andExpect(status().isOk())
		.andExpect(model().size(1))
		.andExpect(model().attributeExists("person"))
		.andExpect(forwardedUrl("person/show"));

	mockMvc.perform(get("/person/Corea").accept(MediaType.APPLICATION_JSON))
		.andExpect(status().isOk())
		.andExpect(content().contentType(MediaType.APPLICATION_JSON))
		.andExpect(jsonPath("$.person.name").value("Corea"));

	mockMvc.perform(get("/person/Corea").accept(MediaType.APPLICATION_XML))
		.andExpect(status().isOk())
		.andExpect(content().contentType(MediaType.APPLICATION_XML))
		.andExpect(xpath("/person/name/text()").string(equalTo("Corea")));
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:40,代码来源:ViewResolutionTests.java

示例7: viewResolver

import org.springframework.web.servlet.view.ContentNegotiatingViewResolver; //导入方法依赖的package包/类
@Bean
@ConditionalOnBean(ViewResolver.class)
@ConditionalOnMissingBean(name = "viewResolver", value = ContentNegotiatingViewResolver.class)
public ContentNegotiatingViewResolver viewResolver(BeanFactory beanFactory) {
	ContentNegotiatingViewResolver resolver = new ContentNegotiatingViewResolver();
	resolver.setContentNegotiationManager(
			beanFactory.getBean(ContentNegotiationManager.class));
	// ContentNegotiatingViewResolver uses all the other view resolvers to locate
	// a view so it should have a high precedence
	resolver.setOrder(Ordered.HIGHEST_PRECEDENCE);
	return resolver;
}
 
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:13,代码来源:WebMvcAutoConfiguration.java

示例8: viewResolver

import org.springframework.web.servlet.view.ContentNegotiatingViewResolver; //导入方法依赖的package包/类
@Bean
public ContentNegotiatingViewResolver viewResolver(BeanFactory beanFactory) {
    ContentNegotiatingViewResolver contentNegotiatingViewResolver = new ContentNegotiatingViewResolver();
    contentNegotiatingViewResolver.setContentNegotiationManager(beanFactory.getBean(ContentNegotiationManager.class));
    contentNegotiatingViewResolver.setViewResolvers(Arrays.asList(pungweViewResolver()));
    contentNegotiatingViewResolver.setDefaultViews(Arrays.asList(mappingJackson2JsonView()));
    contentNegotiatingViewResolver.setOrder(Ordered.HIGHEST_PRECEDENCE);
    return contentNegotiatingViewResolver;
}
 
开发者ID:thunderbird,项目名称:pungwecms,代码行数:10,代码来源:ModuleContextConfig.java

示例9: testContentNegotiation

import org.springframework.web.servlet.view.ContentNegotiatingViewResolver; //导入方法依赖的package包/类
@Test
public void testContentNegotiation() throws Exception {

	Jaxb2Marshaller marshaller = new Jaxb2Marshaller();
	marshaller.setClassesToBeBound(Person.class);

	List<View> viewList = new ArrayList<View>();
	viewList.add(new MappingJacksonJsonView());
	viewList.add(new MarshallingView(marshaller));

	ContentNegotiationManager manager = new ContentNegotiationManager(
			new HeaderContentNegotiationStrategy(), new FixedContentNegotiationStrategy(MediaType.TEXT_HTML));

	ContentNegotiatingViewResolver cnViewResolver = new ContentNegotiatingViewResolver();
	cnViewResolver.setDefaultViews(viewList);
	cnViewResolver.setContentNegotiationManager(manager);
	cnViewResolver.afterPropertiesSet();

	MockMvc mockMvc =
		standaloneSetup(new PersonController())
			.setViewResolvers(cnViewResolver, new InternalResourceViewResolver())
			.build();

	mockMvc.perform(get("/person/Corea"))
		.andExpect(status().isOk())
		.andExpect(model().size(1))
		.andExpect(model().attributeExists("person"))
		.andExpect(forwardedUrl("person/show"));

	mockMvc.perform(get("/person/Corea").accept(MediaType.APPLICATION_JSON))
		.andExpect(status().isOk())
		.andExpect(content().contentType(MediaType.APPLICATION_JSON))
		.andExpect(jsonPath("$.person.name").value("Corea"));

	mockMvc.perform(get("/person/Corea").accept(MediaType.APPLICATION_XML))
		.andExpect(status().isOk())
		.andExpect(content().contentType(MediaType.APPLICATION_XML))
		.andExpect(xpath("/person/name/text()").string(equalTo("Corea")));
}
 
开发者ID:deathspeeder,项目名称:class-guard,代码行数:40,代码来源:ViewResolutionTests.java

示例10: contentNegotiatingViewResolver

import org.springframework.web.servlet.view.ContentNegotiatingViewResolver; //导入方法依赖的package包/类
@Bean
public ViewResolver contentNegotiatingViewResolver(ContentNegotiationManager manager) {
    ContentNegotiatingViewResolver resolver = new ContentNegotiatingViewResolver();

    resolver.setContentNegotiationManager(manager);
    return resolver;
}
 
开发者ID:przodownikR1,项目名称:thymeleaf_kata,代码行数:8,代码来源:WebConfig.java

示例11: contentViewResolver

import org.springframework.web.servlet.view.ContentNegotiatingViewResolver; //导入方法依赖的package包/类
@Autowired
@Bean
public ContentNegotiatingViewResolver contentViewResolver(
		@Qualifier("contentNegotiationManagerFactory") ContentNegotiationManager contentNegotiationManager) {
	ContentNegotiatingViewResolver res = new ContentNegotiatingViewResolver();
	res.setContentNegotiationManager(contentNegotiationManager);
	res.setDefaultViews(Arrays.asList(new MappingJackson2JsonView()));
	return res;

}
 
开发者ID:JensKapitza,项目名称:jsf-exmple,代码行数:11,代码来源:PersistenceConfig.java

示例12: contentNegotiatingViewResolver

import org.springframework.web.servlet.view.ContentNegotiatingViewResolver; //导入方法依赖的package包/类
@Bean
public ContentNegotiatingViewResolver contentNegotiatingViewResolver (final ContentNegotiationManager manager) {
  ContentNegotiatingViewResolver resolver = new ContentNegotiatingViewResolver ();
  resolver.setContentNegotiationManager (manager);
  return resolver;
}
 
开发者ID:dfci-cccb,项目名称:mev,代码行数:7,代码来源:ContentNegotiationConfiguration.java


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