Introduce optimizeLocations flag for resource location filtering on startup

This flag is off by default since it requires jar files with directory entries.

Closes gh-27624
This commit is contained in:
Juergen Hoeller
2021-11-10 14:21:48 +01:00
parent 11a0df3fd1
commit 2a268701c4
8 changed files with 188 additions and 80 deletions

View File

@@ -4170,8 +4170,8 @@ the example:
@Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {
registry.addResourceHandler("/resources/**")
.addResourceLocations("/public", "classpath:/static/")
.setCacheControl(CacheControl.maxAge(365, TimeUnit.DAYS));
.addResourceLocations("/public", "classpath:/static/")
.setCacheControl(CacheControl.maxAge(365, TimeUnit.DAYS));
}
}
@@ -4259,6 +4259,9 @@ re-write URLs to include the version of the jar and can also match against incom
without versions -- for example, from `/jquery/jquery.min.js` to
`/jquery/1.2.0/jquery.min.js`.
TIP: The Java configuration based on `ResourceHandlerRegistry` provides further options
for fine-grained control, e.g. last-modified behavior and optimized resource resolution.
[[webflux-config-path-matching]]

View File

@@ -5738,8 +5738,8 @@ The following listing shows how to do so with Java configuration:
@Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {
registry.addResourceHandler("/resources/**")
.addResourceLocations("/public", "classpath:/static/")
.setCacheControl(CacheControl.maxAge(Duration.ofDays(365)));
.addResourceLocations("/public", "classpath:/static/")
.setCacheControl(CacheControl.maxAge(Duration.ofDays(365)));
}
}
----
@@ -5846,6 +5846,9 @@ re-write URLs to include the version of the jar and can also match against incom
without versions -- for example, from `/jquery/jquery.min.js` to
`/jquery/1.2.0/jquery.min.js`.
TIP: The Java configuration based on `ResourceHandlerRegistry` provides further options
for fine-grained control, e.g. last-modified behavior and optimized resource resolution.
[[mvc-default-servlet-handler]]