Examples of PathExtensionContentNegotiationStrategy


Examples of org.springframework.web.accept.PathExtensionContentNegotiationStrategy

  @Test
  public void resolveViewNameFilenameDefaultView() throws Exception {
    request.setRequestURI("/test.json");

    Map<String, MediaType> mapping = Collections.singletonMap("json", MediaType.APPLICATION_JSON);
    PathExtensionContentNegotiationStrategy pathStrategy = new PathExtensionContentNegotiationStrategy(mapping);
    viewResolver.setContentNegotiationManager(new ContentNegotiationManager(pathStrategy));

    ViewResolver viewResolverMock1 = mock(ViewResolver.class);
    ViewResolver viewResolverMock2 = mock(ViewResolver.class);
    viewResolver.setViewResolvers(Arrays.asList(viewResolverMock1, viewResolverMock2));
View Full Code Here

Examples of org.springframework.web.accept.PathExtensionContentNegotiationStrategy

  public void useRegisteredSuffixPatternMatch() {
    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

Examples of org.springframework.web.accept.PathExtensionContentNegotiationStrategy

  }

  @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() {
View Full Code Here

Examples of org.springframework.web.accept.PathExtensionContentNegotiationStrategy

    }
    mediaTypes.put("html", defaultContentType);
   
    List<ContentNegotiationStrategy> strategies = new ArrayList<ContentNegotiationStrategy>();
    if (this.favorPathExtension) {
      PathExtensionContentNegotiationStrategy strategy;
      if (this.servletContext != null) {
        strategy = new ServletPathExtensionContentNegotiationStrategy(this.servletContext, this.mediaTypes);
      } else {
        strategy = new PathExtensionContentNegotiationStrategy(this.mediaTypes);
      }
      strategies.add(strategy);
    }

    if (this.favorParameter) {
      ParameterContentNegotiationStrategy strategy = new ParameterContentNegotiationStrategy(this.mediaTypes);
      strategy.setParameterName(this.parameterName);
      strategies.add(strategy);
    }

    if (!this.ignoreAcceptHeader) {
      strategies.add(new HeaderContentNegotiationStrategy());
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.