use of org.springframework.http.converter.ResourceHttpMessageConverter in project spring-framework by spring-projects.
the class ResourceHttpRequestHandler method afterPropertiesSet.
@Override
public void afterPropertiesSet() throws Exception {
if (logger.isWarnEnabled() && CollectionUtils.isEmpty(this.locations)) {
logger.warn("Locations list is empty. No resources will be served unless a " + "custom ResourceResolver is configured as an alternative to PathResourceResolver.");
}
if (this.resourceResolvers.isEmpty()) {
this.resourceResolvers.add(new PathResourceResolver());
}
initAllowedLocations();
if (this.resourceHttpMessageConverter == null) {
this.resourceHttpMessageConverter = new ResourceHttpMessageConverter();
}
if (this.resourceRegionHttpMessageConverter == null) {
this.resourceRegionHttpMessageConverter = new ResourceRegionHttpMessageConverter();
}
this.contentNegotiationStrategy = initContentNegotiationStrategy();
}
use of org.springframework.http.converter.ResourceHttpMessageConverter in project spring-boot by spring-projects.
the class RestTemplateBuilderTests method messageConvertersShouldReplaceExisting.
@Test
public void messageConvertersShouldReplaceExisting() throws Exception {
RestTemplate template = this.builder.messageConverters(new ResourceHttpMessageConverter()).messageConverters(Collections.singleton(this.messageConverter)).build();
assertThat(template.getMessageConverters()).containsOnly(this.messageConverter);
}
use of org.springframework.http.converter.ResourceHttpMessageConverter in project spring-boot by spring-projects.
the class RestTemplateBuilderTests method additionalMessageConvertersShouldAddToExisting.
@Test
public void additionalMessageConvertersShouldAddToExisting() throws Exception {
HttpMessageConverter<?> resourceConverter = new ResourceHttpMessageConverter();
RestTemplate template = this.builder.messageConverters(resourceConverter).additionalMessageConverters(this.messageConverter).build();
assertThat(template.getMessageConverters()).containsOnly(resourceConverter, this.messageConverter);
}
Aggregations