The list of supported contentCodings can
be configured, in order of preference, and each coding must be associated
with extensions.
Note that this resolver must be ordered ahead of a
VersionResourceResolver with a content-based, version strategy to
ensure the version calculation is not impacted by the encoding.
| Modifier and Type | Class and Description |
|---|---|
| pack-priv static class |
| Modifier and Type | Field and Description |
|---|---|
| private final List | |
| public static final List | DEFAULT_CODINGS
The default content codings. |
| private final Map |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| private String | |
| public List | |
| private String | |
| public Map | |
| public void | registerExtension(String
the content coding coding, String the associated file extension extension)Java config friendly alternative to |
| protected Resource | resolveResourceInternal(HttpServletRequest request, String requestPath, List<? extends Resource> locations, ResourceResolverChain chain)
Implements abstract org.
|
| protected String | resolveUrlPathInternal(String resourceUrlPath, List<? extends Resource> locations, ResourceResolverChain chain)
Implements abstract org.
|
| public void | setContentCodings(List<String>
one or more supported content codings codings)Configure the supported content codings in order of preference. |
| public void | setExtensions(Map<String, String>
the extensions to use. extensions)Configure mappings from content codings to file extensions. |
| contentCodings | back to summary |
|---|---|
| private final List<String> contentCodings | |
| DEFAULT_CODINGS | back to summary |
|---|---|
| public static final List<String> DEFAULT_CODINGS The default content codings. | |
| extensions | back to summary |
|---|---|
| private final Map<String, String> extensions | |
| EncodedResourceResolver | back to summary |
|---|---|
| public EncodedResourceResolver() | |
| getAcceptEncoding | back to summary |
|---|---|
private String getAcceptEncoding(HttpServletRequest request)
| |
| getContentCodings | back to summary |
|---|---|
| public List Return a read-only list with the supported content codings. | |
| getExtension | back to summary |
|---|---|
| private String getExtension(String coding) | |
| getExtensions | back to summary |
|---|---|
| public Map Return a read-only map with coding-to-extension mappings. | |
| registerExtension | back to summary |
|---|---|
| public void registerExtension(String coding, String extension) Java config friendly alternative to | |
| resolveResourceInternal | back to summary |
|---|---|
| protected Resource resolveResourceInternal(HttpServletRequest request, String requestPath, List<? extends Resource> locations, ResourceResolverChain chain) Implements abstract org. | |
| resolveUrlPathInternal | back to summary |
|---|---|
| protected String resolveUrlPathInternal(String resourceUrlPath, List<? extends Resource> locations, ResourceResolverChain chain) Implements abstract org. | |
| setContentCodings | back to summary |
|---|---|
| public void setContentCodings(List<String> codings) Configure the supported content codings in order of preference. The first coding that is present in the "Accept-Encoding" header for a given request, and that has a file present with the associated extension, is used. Note Each coding must be associated with a file
extension via By default this property is set to ["br", "gzip"]. | |
| setExtensions | back to summary |
|---|---|
| public void setExtensions(Map<String, String> extensions) Configure mappings from content codings to file extensions. A dot "." will be prepended in front of the extension value if not present. By default this is configured with ["br" -> ".br"] and ["gzip" -> ".gz"].
| |
HttpResource.
| Modifier and Type | Field and Description |
|---|---|
| private final String | |
| private final Resource | |
| private final Resource |
| Access | Constructor and Description |
|---|---|
| pack-priv |
| coding | back to summary |
|---|---|
| private final String coding | |
| encoded | back to summary |
|---|---|
| private final Resource encoded | |
| original | back to summary |
|---|---|
| private final Resource original | |
| EncodedResource | back to summary |
|---|---|
| pack-priv EncodedResource(Resource original, String coding, String extension) throws IOException | |
| contentLength | back to summary |
|---|---|
| public long contentLength() throws IOException Overrides org. Implements org. Doc from org. Determine the content length for this resource.
| |
| createRelative | back to summary |
|---|---|
| public Resource createRelative(String relativePath) throws IOException Overrides org. Implements org. Doc from org. Create a resource relative to this resource.
| |
| exists | back to summary |
|---|---|
| public boolean exists() Overrides org. Implements org. Doc from org. Determine whether this resource actually exists in physical form. This method performs a definitive existence check, whereas the
existence of a
| |
| getContentAsByteArray | back to summary |
|---|---|
| public byte[] getContentAsByteArray() throws IOException Overrides default org. Doc from org. Return the contents of this resource as a byte array.
| |
| getContentAsString | back to summary |
|---|---|
| public String getContentAsString(Charset charset) throws IOException Overrides default org. Doc from org. Return the contents of this resource as a string, using the specified charset.
| |
| getDescription | back to summary |
|---|---|
| public String getDescription() Implements org. Doc from org. Return a description for this resource, to be used for error output when working with the resource. Implementations are also encouraged to return this value
from their
| |
| getFile | back to summary |
|---|---|
| public File getFile() throws IOException Overrides org. Implements org. Doc from org. Return a File handle for this resource.
| |
| getFilename | back to summary |
|---|---|
| public String getFilename() Overrides org. Implements org. Doc from org. Determine the filename for this resource — typically the last
part of the path — for example, Returns Implementations are encouraged to return the filename unencoded. | |
| getInputStream | back to summary |
|---|---|
| public InputStream getInputStream() throws IOException Implements org. Doc from org. Return an It is expected that each call creates a fresh stream. This requirement is particularly important when you consider an API such
as JavaMail, which needs to be able to read the stream multiple times when
creating mail attachments. For such a use case, it is required
that each
| |
| getResponseHeaders | back to summary |
|---|---|
| public HttpHeaders getResponseHeaders() Implements org. Doc from org. The HTTP headers to be contributed to the HTTP response that serves the current resource.
| |
| getURI | back to summary |
|---|---|
| public URI getURI() throws IOException Overrides org. Implements org. Doc from org. Return a URI handle for this resource.
| |
| getURL | back to summary |
|---|---|
| public URL getURL() throws IOException Overrides org. Implements org. Doc from org. Return a URL handle for this resource.
| |
| isFile | back to summary |
|---|---|
| public boolean isFile() Overrides org. Overrides default org. Doc from org. Determine whether this resource represents a file in a file system. A value of This is conservatively
| |
| isOpen | back to summary |
|---|---|
| public boolean isOpen() Overrides org. Overrides default org. Doc from org. Indicate whether this resource represents a handle with an open stream.
If Will be
| |
| isReadable | back to summary |
|---|---|
| public boolean isReadable() Overrides org. Overrides default org. Doc from org. Indicate whether non-empty contents of this resource can be read via
Will be
| |
| lastModified | back to summary |
|---|---|
| public long lastModified() throws IOException Overrides org. Implements org. Doc from org. Determine the last-modified timestamp for this resource.
| |
| readableChannel | back to summary |
|---|---|
| public ReadableByteChannel readableChannel() throws IOException Overrides org. Overrides default org. Doc from org. Return a It is expected that each call creates a fresh channel. The default implementation returns
| |