List of usage examples for org.springframework.web.reactive.resource PathResourceResolver setAllowedLocations
public void setAllowedLocations(@Nullable Resource... locations)
From source file:org.springframework.web.reactive.resource.ResourceWebHandler.java
/** * Look for a {@code PathResourceResolver} among the configured resource * resolvers and set its {@code allowedLocations} property (if empty) to * match the {@link #setLocations locations} configured on this class. *//* w ww . j a v a 2 s. c om*/ protected void initAllowedLocations() { if (CollectionUtils.isEmpty(this.locations)) { if (logger.isWarnEnabled()) { logger.warn("Locations list is empty. No resources will be served unless a " + "custom ResourceResolver is configured as an alternative to PathResourceResolver."); } return; } for (int i = getResourceResolvers().size() - 1; i >= 0; i--) { if (getResourceResolvers().get(i) instanceof PathResourceResolver) { PathResourceResolver resolver = (PathResourceResolver) getResourceResolvers().get(i); if (ObjectUtils.isEmpty(resolver.getAllowedLocations())) { resolver.setAllowedLocations(getLocations().toArray(new Resource[getLocations().size()])); } break; } } }