Java 类org.springframework.web.servlet.view.ContentNegotiatingViewResolver 实例源码

项目:devops-cstack    文件:CloudUnitApplicationContext.java   
@Bean
public ViewResolver contentNegotiatingViewResolver() {
    logger.debug("Configuring the ContentNegotiatingViewResolver");
    ContentNegotiatingViewResolver viewResolver = new ContentNegotiatingViewResolver();
    List<ViewResolver> viewResolvers = new ArrayList<ViewResolver>();

    UrlBasedViewResolver urlBasedViewResolver = new UrlBasedViewResolver();
    urlBasedViewResolver.setViewClass(JstlView.class);
    urlBasedViewResolver.setSuffix(".html");
    viewResolvers.add(urlBasedViewResolver);

    viewResolver.setViewResolvers(viewResolvers);

    List<View> defaultViews = new ArrayList<View>();
    defaultViews.add(new MappingJackson2JsonView());
    viewResolver.setDefaultViews(defaultViews);

    return viewResolver;
}
项目:spring4-understanding    文件:ViewResolverRegistry.java   
private void initContentNegotiatingViewResolver(View[] defaultViews) {

        // ContentNegotiatingResolver in the registry: elevate its precedence!
        this.order = (this.order == null ? Ordered.HIGHEST_PRECEDENCE : this.order);

        if (this.contentNegotiatingResolver != null) {
            if (!ObjectUtils.isEmpty(defaultViews)) {
                if (!CollectionUtils.isEmpty(this.contentNegotiatingResolver.getDefaultViews())) {
                    List<View> views = new ArrayList<View>(this.contentNegotiatingResolver.getDefaultViews());
                    views.addAll(Arrays.asList(defaultViews));
                    this.contentNegotiatingResolver.setDefaultViews(views);
                }
            }
        }
        else {
            this.contentNegotiatingResolver = new ContentNegotiatingViewResolver();
            this.contentNegotiatingResolver.setDefaultViews(Arrays.asList(defaultViews));
            this.contentNegotiatingResolver.setViewResolvers(this.viewResolvers);
            this.contentNegotiatingResolver.setContentNegotiationManager(this.contentNegotiationManager);
        }
    }
项目:spring4-understanding    文件:ViewResolversBeanDefinitionParser.java   
private BeanDefinition createContentNegotiatingViewResolver(Element resolverElement, ParserContext context) {
    RootBeanDefinition beanDef = new RootBeanDefinition(ContentNegotiatingViewResolver.class);
    beanDef.setSource(context.extractSource(resolverElement));
    beanDef.setRole(BeanDefinition.ROLE_INFRASTRUCTURE);
    MutablePropertyValues values = beanDef.getPropertyValues();

    List<Element> elements = DomUtils.getChildElementsByTagName(resolverElement, new String[] {"default-views"});
    if (!elements.isEmpty()) {
        ManagedList<Object> list = new ManagedList<Object>();
        for (Element element : DomUtils.getChildElementsByTagName(elements.get(0), "bean", "ref")) {
            list.add(context.getDelegate().parsePropertySubElement(element, null));
        }
        values.add("defaultViews", list);
    }
    if (resolverElement.hasAttribute("use-not-acceptable")) {
        values.add("useNotAcceptableStatusCode", resolverElement.getAttribute("use-not-acceptable"));
    }
    Object manager = getContentNegotiationManager(context);
    if (manager != null) {
        values.add("contentNegotiationManager", manager);
    }
    return beanDef;
}
项目:spring4-understanding    文件:MvcNamespaceTests.java   
@Test
public void testContentNegotiationManager() throws Exception {
    loadBeanDefinitions("mvc-config-content-negotiation-manager.xml", 15);

    RequestMappingHandlerMapping mapping = appContext.getBean(RequestMappingHandlerMapping.class);
    ContentNegotiationManager manager = mapping.getContentNegotiationManager();

    MockHttpServletRequest request = new MockHttpServletRequest("GET", "/foo.xml");
    NativeWebRequest webRequest = new ServletWebRequest(request);
    assertEquals(Arrays.asList(MediaType.valueOf("application/rss+xml")), manager.resolveMediaTypes(webRequest));

    ViewResolverComposite compositeResolver = this.appContext.getBean(ViewResolverComposite.class);
    assertNotNull(compositeResolver);
    assertEquals("Actual: " + compositeResolver.getViewResolvers(), 1, compositeResolver.getViewResolvers().size());

    ViewResolver resolver = compositeResolver.getViewResolvers().get(0);
    assertEquals(ContentNegotiatingViewResolver.class, resolver.getClass());
    ContentNegotiatingViewResolver cnvr = (ContentNegotiatingViewResolver) resolver;
    assertSame(manager, cnvr.getContentNegotiationManager());
}
项目:spring4-understanding    文件:MvcNamespaceTests.java   
@Test
public void testViewResolutionWithContentNegotiation() throws Exception {
    loadBeanDefinitions("mvc-config-view-resolution-content-negotiation.xml", 7);

    ViewResolverComposite compositeResolver = this.appContext.getBean(ViewResolverComposite.class);
    assertNotNull(compositeResolver);
    assertEquals(1, compositeResolver.getViewResolvers().size());
    assertEquals(Ordered.HIGHEST_PRECEDENCE, compositeResolver.getOrder());

    List<ViewResolver> resolvers = compositeResolver.getViewResolvers();
    assertEquals(ContentNegotiatingViewResolver.class, resolvers.get(0).getClass());
    ContentNegotiatingViewResolver cnvr = (ContentNegotiatingViewResolver) resolvers.get(0);
    assertEquals(7, cnvr.getViewResolvers().size());
    assertEquals(1, cnvr.getDefaultViews().size());
    assertTrue(cnvr.isUseNotAcceptableStatusCode());

    String beanName = "contentNegotiationManager";
    DirectFieldAccessor accessor = new DirectFieldAccessor(cnvr);
    ContentNegotiationManager manager = (ContentNegotiationManager) accessor.getPropertyValue(beanName);
    assertNotNull(manager);
    assertSame(manager, this.appContext.getBean(ContentNegotiationManager.class));
}
项目:enterkey-framework    文件:Application.java   
@Bean
public ViewResolver viewResolver() {
    ContentNegotiatingViewResolver resolver = new ContentNegotiatingViewResolver();

    List<View> defaultViews = new ArrayList<View>();
    defaultViews.add(new MappingJackson2JsonView());
    resolver.setDefaultViews(defaultViews);
    resolver.setOrder(0);

    List<ViewResolver> viewResolvers = new ArrayList<ViewResolver>();
    InternalResourceViewResolver internalResourceViewResolver = new InternalResourceViewResolver();
    internalResourceViewResolver.setPrefix("/WEB-INF/view/");
    internalResourceViewResolver.setSuffix(".jsp");
    internalResourceViewResolver.setOrder(1);
    viewResolvers.add(internalResourceViewResolver);
    resolver.setViewResolvers(viewResolvers);

    return resolver;
}
项目:flowable-engine    文件:DispatcherServletConfiguration.java   
@Bean
public ViewResolver contentNegotiatingViewResolver() {
    LOGGER.debug("Configuring the ContentNegotiatingViewResolver");
    ContentNegotiatingViewResolver viewResolver = new ContentNegotiatingViewResolver();
    List<ViewResolver> viewResolvers = new ArrayList<>();

    UrlBasedViewResolver urlBasedViewResolver = new UrlBasedViewResolver();
    urlBasedViewResolver.setViewClass(JstlView.class);
    urlBasedViewResolver.setPrefix("/WEB-INF/pages/");
    urlBasedViewResolver.setSuffix(".jsp");
    viewResolvers.add(urlBasedViewResolver);

    viewResolver.setViewResolvers(viewResolvers);

    List<View> defaultViews = new ArrayList<>();
    defaultViews.add(new MappingJackson2JsonView());
    viewResolver.setDefaultViews(defaultViews);

    return viewResolver;
}
项目:catnap    文件:DelegatingCatnapWebMvcConfiguration.java   
@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;
}
项目:catnap    文件:WidgetConfiguration.java   
@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;
}
项目:opentipbot    文件:WebAppContext.java   
@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;

}
项目:FeedbackCollectionAndMgmtSystem    文件:AppConfig.java   
@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;
}
项目:Sound.je    文件:TemplateConfig.java   
/**
 * 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;
}
项目:pswot-cloud-java-spring-webapp    文件:AppWebConfiguration.java   
@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;
}
项目:spring4-understanding    文件:ViewResolverRegistryTests.java   
@Test
public void contentNegotiation() {
    MappingJackson2JsonView view = new MappingJackson2JsonView();
    this.registry.enableContentNegotiation(view);
    ContentNegotiatingViewResolver resolver = checkAndGetResolver(ContentNegotiatingViewResolver.class);
    assertEquals(Arrays.asList(view), resolver.getDefaultViews());
    assertEquals(Ordered.HIGHEST_PRECEDENCE, this.registry.getOrder());
}
项目:spring4-understanding    文件:ViewResolverRegistryTests.java   
@Test
public void contentNegotiationAddsDefaultViewRegistrations() {
    MappingJackson2JsonView view1 = new MappingJackson2JsonView();
    this.registry.enableContentNegotiation(view1);

    ContentNegotiatingViewResolver resolver1 = checkAndGetResolver(ContentNegotiatingViewResolver.class);
    assertEquals(Arrays.asList(view1), resolver1.getDefaultViews());

    MarshallingView view2 = new MarshallingView();
    this.registry.enableContentNegotiation(view2);

    ContentNegotiatingViewResolver resolver2 = checkAndGetResolver(ContentNegotiatingViewResolver.class);
    assertEquals(Arrays.asList(view1, view2), resolver2.getDefaultViews());
    assertSame(resolver1, resolver2);
}
项目:spring4-understanding    文件:ViewResolutionTests.java   
@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")));
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:WebMvcAutoConfiguration.java   
@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;
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:WebMvcAutoConfigurationTests.java   
@Test
public void customContentNegotiatingViewResolver() throws Exception {
    load(CustomContentNegotiatingViewResolver.class);
    Map<String, ContentNegotiatingViewResolver> beans = this.context
            .getBeansOfType(ContentNegotiatingViewResolver.class);
    assertThat(beans.size()).isEqualTo(1);
    assertThat(beans.keySet().iterator().next()).isEqualTo("myViewResolver");
}
项目:spring-boot-concourse    文件:WebMvcAutoConfiguration.java   
@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;
}
项目:spring-boot-concourse    文件:WebMvcAutoConfigurationTests.java   
@Test
public void customContentNegotiatingViewResolver() throws Exception {
    load(CustomContentNegotiatingViewResolver.class);
    Map<String, ContentNegotiatingViewResolver> beans = this.context
            .getBeansOfType(ContentNegotiatingViewResolver.class);
    assertThat(beans.size()).isEqualTo(1);
    assertThat(beans.keySet().iterator().next()).isEqualTo("myViewResolver");
}
项目:contestparser    文件:WebMvcAutoConfiguration.java   
@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;
}
项目:contestparser    文件:WebMvcAutoConfigurationTests.java   
@Test
public void customContentNegotiatingViewResolver() throws Exception {
    load(CustomContentNegotiatingViewResolver.class);
    Map<String, ContentNegotiatingViewResolver> beans = this.context
            .getBeansOfType(ContentNegotiatingViewResolver.class);
    assertThat(beans.size(), equalTo(1));
    assertThat(beans.keySet().iterator().next(), equalTo("myViewResolver"));
}
项目:pungwecms    文件:ModuleContextConfig.java   
@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;
}
项目:mybus    文件:WebApplicationConfig.java   
@Bean
public ContentNegotiatingViewResolver viewResolver() {
    ContentNegotiatingViewResolver resolver = new ContentNegotiatingViewResolver();
    List<ViewResolver> viewResolvers = new ArrayList<>(1);
    viewResolvers.add(jspViewResolver());
    resolver.setViewResolvers(viewResolvers);
    List<View> views = new ArrayList<>();
    views.add(jsonView());
    resolver.setDefaultViews(views);
    return resolver;
}
项目:class-guard    文件:ViewResolutionTests.java   
@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")));
}
项目:thymeleaf_kata    文件:WebConfig.java   
@Bean
public ViewResolver contentNegotiatingViewResolver(ContentNegotiationManager manager) {
    ContentNegotiatingViewResolver resolver = new ContentNegotiatingViewResolver();

    resolver.setContentNegotiationManager(manager);
    return resolver;
}
项目:jsf-exmple    文件:PersistenceConfig.java   
@Autowired
@Bean
public ContentNegotiatingViewResolver contentViewResolver(
        @Qualifier("contentNegotiationManagerFactory") ContentNegotiationManager contentNegotiationManager) {
    ContentNegotiatingViewResolver res = new ContentNegotiatingViewResolver();
    res.setContentNegotiationManager(contentNegotiationManager);
    res.setDefaultViews(Arrays.asList(new MappingJackson2JsonView()));
    return res;

}
项目:maven-framework-project    文件:WebMvcConfig.java   
@Bean
public ContentNegotiatingViewResolver contentNegotiatingViewResolver() {
    ContentNegotiatingViewResolver result = new ContentNegotiatingViewResolver();
    Map<String, String> mediaTypes = new HashMap<String, String>();
    mediaTypes.put("json", MediaType.APPLICATION_JSON_VALUE);
    result.setMediaTypes(mediaTypes);
    MappingJacksonJsonView jacksonView = new MappingJacksonJsonView();
    jacksonView.setExtractValueFromSingleKeyModel(true);
    Set<String> modelKeys = new HashSet<String>();
    modelKeys.add("events");
    modelKeys.add("event");
    jacksonView.setModelKeys(modelKeys);
    result.setDefaultViews(Collections.singletonList((View) jacksonView));
    return result;
}
项目:maven-framework-project    文件:WebMvcConfig.java   
@Bean
public ContentNegotiatingViewResolver contentNegotiatingViewResolver() {
    ContentNegotiatingViewResolver result = new ContentNegotiatingViewResolver();
    Map<String, String> mediaTypes = new HashMap<String, String>();
    mediaTypes.put("json", MediaType.APPLICATION_JSON_VALUE);
    result.setMediaTypes(mediaTypes);
    MappingJacksonJsonView jacksonView = new MappingJacksonJsonView();
    jacksonView.setExtractValueFromSingleKeyModel(true);
    Set<String> modelKeys = new HashSet<String>();
    modelKeys.add("events");
    modelKeys.add("event");
    jacksonView.setModelKeys(modelKeys);
    result.setDefaultViews(Collections.singletonList((View) jacksonView));
    return result;
}
项目:maven-framework-project    文件:WebMvcConfig.java   
@Bean
public ContentNegotiatingViewResolver contentNegotiatingViewResolver() {
    ContentNegotiatingViewResolver result = new ContentNegotiatingViewResolver();
    Map<String, String> mediaTypes = new HashMap<String, String>();
    mediaTypes.put("json", MediaType.APPLICATION_JSON_VALUE);
    result.setMediaTypes(mediaTypes);
    MappingJacksonJsonView jacksonView = new MappingJacksonJsonView();
    jacksonView.setExtractValueFromSingleKeyModel(true);
    Set<String> modelKeys = new HashSet<String>();
    modelKeys.add("events");
    modelKeys.add("event");
    jacksonView.setModelKeys(modelKeys);
    result.setDefaultViews(Collections.singletonList((View) jacksonView));
    return result;
}
项目:maven-framework-project    文件:WebMvcConfig.java   
@Bean
public ContentNegotiatingViewResolver contentNegotiatingViewResolver() {
    ContentNegotiatingViewResolver result = new ContentNegotiatingViewResolver();
    Map<String, String> mediaTypes = new HashMap<String, String>();
    mediaTypes.put("json", MediaType.APPLICATION_JSON_VALUE);
    result.setMediaTypes(mediaTypes);
    MappingJacksonJsonView jacksonView = new MappingJacksonJsonView();
    jacksonView.setExtractValueFromSingleKeyModel(true);
    Set<String> modelKeys = new HashSet<String>();
    modelKeys.add("events");
    modelKeys.add("event");
    jacksonView.setModelKeys(modelKeys);
    result.setDefaultViews(Collections.singletonList((View) jacksonView));
    return result;
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:WebMvcAutoConfigurationTests.java   
@Bean
public ContentNegotiatingViewResolver myViewResolver() {
    return new ContentNegotiatingViewResolver();
}
项目:spring-boot-concourse    文件:WebMvcAutoConfigurationTests.java   
@Bean
public ContentNegotiatingViewResolver myViewResolver() {
    return new ContentNegotiatingViewResolver();
}
项目:contestparser    文件:WebMvcAutoConfigurationTests.java   
@Bean
public ContentNegotiatingViewResolver myViewResolver() {
    return new ContentNegotiatingViewResolver();
}
项目:mev    文件:ContentNegotiationConfiguration.java   
@Bean
public ContentNegotiatingViewResolver contentNegotiatingViewResolver (final ContentNegotiationManager manager) {
  ContentNegotiatingViewResolver resolver = new ContentNegotiatingViewResolver ();
  resolver.setContentNegotiationManager (manager);
  return resolver;
}