Package org.springframework.web.accept

Examples of org.springframework.web.accept.ContentNegotiationManager


  }

  @Test
  public void setDefaultContentType() throws Exception {
    this.configurer.defaultContentType(MediaType.APPLICATION_JSON);
    ContentNegotiationManager manager = this.configurer.getContentNegotiationManager();

    assertEquals(Arrays.asList(MediaType.APPLICATION_JSON), manager.resolveMediaTypes(this.webRequest));
  }
View Full Code Here


  }

  @Test
  public void setDefaultContentTypeStrategy() throws Exception {
    this.configurer.defaultContentTypeStrategy(new FixedContentNegotiationStrategy(MediaType.APPLICATION_JSON));
    ContentNegotiationManager manager = this.configurer.getContentNegotiationManager();

    assertEquals(Arrays.asList(MediaType.APPLICATION_JSON), manager.resolveMediaTypes(this.webRequest));
  }
View Full Code Here

    context.registerSingleton("velocityConfigurer", VelocityConfigurer.class);
    context.registerSingleton("tilesConfigurer", TilesConfigurer.class);
    context.registerSingleton("groovyMarkupConfigurer", GroovyMarkupConfigurer.class);
    this.registry = new ViewResolverRegistry();
    this.registry.setApplicationContext(context);
    this.registry.setContentNegotiationManager(new ContentNegotiationManager());
  }
View Full Code Here

    assertTrue(this.handlerMapping.useSuffixPatternMatch());
    assertFalse(this.handlerMapping.useRegisteredSuffixPatternMatch());

    Map<String, MediaType> fileExtensions = Collections.singletonMap("json", MediaType.APPLICATION_JSON);
    PathExtensionContentNegotiationStrategy strategy = new PathExtensionContentNegotiationStrategy(fileExtensions);
    ContentNegotiationManager manager = new ContentNegotiationManager(strategy);

    this.handlerMapping.setContentNegotiationManager(manager);
    this.handlerMapping.setUseRegisteredSuffixPatternMatch(true);
    this.handlerMapping.afterPropertiesSet();
View Full Code Here

  @Test
  public void useRegisteredSuffixPatternMatchInitialization() {
    Map<String, MediaType> fileExtensions = Collections.singletonMap("json", MediaType.APPLICATION_JSON);
    PathExtensionContentNegotiationStrategy strategy = new PathExtensionContentNegotiationStrategy(fileExtensions);
    ContentNegotiationManager manager = new ContentNegotiationManager(strategy);

    final Set<String> extensions = new HashSet<String>();

    RequestMappingHandlerMapping hm = new RequestMappingHandlerMapping() {
      @Override
View Full Code Here

    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);
View Full Code Here

    }

    if (this.defaultContentType != null) {
      strategies.add(new FixedContentNegotiationStrategy(this.defaultContentType));
    }
    this.contentNegotiationManager = new ContentNegotiationManager(strategies);
   
  }
View Full Code Here

    addDefaultHttpMessageConverters( messageConverters );
    //}

    interceptorRegistry.addInterceptor( new ConversionServiceExposingInterceptor( conversionService ) );

    ContentNegotiationManager contentNegotiationManager;

    try {
      contentNegotiationManager = contentNegotiationConfigurer.getContentNegotiationManager();
    }
    catch ( Exception e ) {
View Full Code Here

TOP

Related Classes of org.springframework.web.accept.ContentNegotiationManager

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.