Example usage for org.springframework.web.servlet.resource PathResourceResolver setLocationCharsets

List of usage examples for org.springframework.web.servlet.resource PathResourceResolver setLocationCharsets

Introduction

In this page you can find the example usage for org.springframework.web.servlet.resource PathResourceResolver setLocationCharsets.

Prototype

public void setLocationCharsets(Map<Resource, Charset> locationCharsets) 

Source Link

Document

Configure charsets associated with locations.

Usage

From source file:org.springframework.web.servlet.resource.ResourceHttpRequestHandler.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 w w  .  j a v  a  2s.  com
protected void initAllowedLocations() {
    if (CollectionUtils.isEmpty(this.locations)) {
        return;
    }
    for (int i = getResourceResolvers().size() - 1; i >= 0; i--) {
        if (getResourceResolvers().get(i) instanceof PathResourceResolver) {
            PathResourceResolver pathResolver = (PathResourceResolver) getResourceResolvers().get(i);
            if (ObjectUtils.isEmpty(pathResolver.getAllowedLocations())) {
                pathResolver.setAllowedLocations(getLocations().toArray(new Resource[getLocations().size()]));
            }
            if (this.urlPathHelper != null) {
                pathResolver.setLocationCharsets(this.locationCharsets);
                pathResolver.setUrlPathHelper(this.urlPathHelper);
            }
            break;
        }
    }
}