Skip to content

Commit 581fa14

Browse files
committed
Merge branch '5.3.x'
2 parents eeebea1 + 1439c5b commit 581fa14

File tree

4 files changed

+32
-14
lines changed

4 files changed

+32
-14
lines changed

spring-webflux/src/main/java/org/springframework/web/reactive/resource/WebJarsResourceResolver.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,15 +30,18 @@
3030
* attempts to find a matching versioned resource contained in a WebJar JAR file.
3131
*
3232
* <p>This allows WebJars.org users to write version agnostic paths in their templates,
33-
* like {@code <script src="/jquery/jquery.min.js"/>}.
34-
* This path will be resolved to the unique version {@code <script src="/jquery/1.2.0/jquery.min.js"/>},
33+
* like {@code <script src="/webjars/jquery/jquery.min.js"/>}.
34+
* This path will be resolved to the unique version {@code <script src="/webjars/jquery/1.2.0/jquery.min.js"/>},
3535
* which is a better fit for HTTP caching and version management in applications.
3636
*
3737
* <p>This also resolves resources for version agnostic HTTP requests {@code "GET /jquery/jquery.min.js"}.
3838
*
3939
* <p>This resolver requires the {@code org.webjars:webjars-locator-core} library
4040
* on the classpath and is automatically registered if that library is present.
4141
*
42+
* <p>Be aware that {@code WebJarAssetLocator} constructor performs a classpath scanning that
43+
* could slow down application startup.
44+
*
4245
* @author Rossen Stoyanchev
4346
* @author Brian Clozel
4447
* @since 5.0

spring-webmvc/src/main/java/org/springframework/web/servlet/resource/WebJarsResourceResolver.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,18 @@
2929
* attempts to find a matching versioned resource contained in a WebJar JAR file.
3030
*
3131
* <p>This allows WebJars.org users to write version agnostic paths in their templates,
32-
* like {@code <script src="/jquery/jquery.min.js"/>}.
33-
* This path will be resolved to the unique version {@code <script src="/jquery/1.2.0/jquery.min.js"/>},
32+
* like {@code <script src="/webjars/jquery/jquery.min.js"/>}.
33+
* This path will be resolved to the unique version {@code <script src="/webjars/jquery/1.2.0/jquery.min.js"/>},
3434
* which is a better fit for HTTP caching and version management in applications.
3535
*
3636
* <p>This also resolves resources for version agnostic HTTP requests {@code "GET /jquery/jquery.min.js"}.
3737
*
3838
* <p>This resolver requires the {@code org.webjars:webjars-locator-core} library
3939
* on the classpath and is automatically registered if that library is present.
4040
*
41+
* <p>Be aware that {@code WebJarAssetLocator} constructor performs a classpath scanning that
42+
* could slow down application startup.
43+
*
4144
* @author Brian Clozel
4245
* @since 4.2
4346
* @see org.springframework.web.servlet.config.annotation.ResourceChainRegistration

src/docs/asciidoc/web/webflux.adoc

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4498,12 +4498,18 @@ Note that, when using both `EncodedResourceResolver` (for example, Gzip, Brotli
44984498
`VersionedResourceResolver`, they must be registered in that order, to ensure content-based
44994499
versions are always computed reliably based on the unencoded file.
45004500

4501-
https://www.webjars.org/documentation[WebJars] are also supported through the
4501+
For https://www.webjars.org/documentation[WebJars], versioned URLs like
4502+
`/webjars/jquery/1.2.0/jquery.min.js` are the recommended and most efficient way to use them.
4503+
The related resource location is configured out of the box with Spring Boot (or can be configured
4504+
manually via `ResourceHandlerRegistry`) and does not require to add the
4505+
`org.webjars:webjars-locator-core` dependency.
4506+
4507+
Version-less URLs like `/webjars/jquery/jquery.min.js` are supported through the
45024508
`WebJarsResourceResolver` which is automatically registered when the
4503-
`org.webjars:webjars-locator-core` library is present on the classpath. The resolver can
4504-
re-write URLs to include the version of the jar and can also match against incoming URLs
4505-
without versions -- for example, from `/jquery/jquery.min.js` to
4506-
`/jquery/1.2.0/jquery.min.js`.
4509+
`org.webjars:webjars-locator-core` library is present on the classpath, at the cost of a
4510+
classpath scanning that could slow down application startup. The resolver can re-write URLs to
4511+
include the version of the jar and can also match against incoming URLs without versions
4512+
-- for example, from `/webjars/jquery/jquery.min.js` to `/webjars/jquery/1.2.0/jquery.min.js`.
45074513

45084514
TIP: The Java configuration based on `ResourceHandlerRegistry` provides further options
45094515
for fine-grained control, e.g. last-modified behavior and optimized resource resolution.

src/docs/asciidoc/web/webmvc.adoc

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6104,12 +6104,18 @@ Note that, when using both `EncodedResourceResolver` (for example, for serving g
61046104
brotli-encoded resources) and `VersionResourceResolver`, you must register them in this order.
61056105
That ensures content-based versions are always computed reliably, based on the unencoded file.
61066106

6107-
https://www.webjars.org/documentation[WebJars] are also supported through the
6107+
For https://www.webjars.org/documentation[WebJars], versioned URLs like
6108+
`/webjars/jquery/1.2.0/jquery.min.js` are the recommended and most efficient way to use them.
6109+
The related resource location is configured out of the box with Spring Boot (or can be configured
6110+
manually via `ResourceHandlerRegistry`) and does not require to add the
6111+
`org.webjars:webjars-locator-core` dependency.
6112+
6113+
Version-less URLs like `/webjars/jquery/jquery.min.js` are supported through the
61086114
`WebJarsResourceResolver` which is automatically registered when the
6109-
`org.webjars:webjars-locator-core` library is present on the classpath. The resolver can
6110-
re-write URLs to include the version of the jar and can also match against incoming URLs
6111-
without versions -- for example, from `/jquery/jquery.min.js` to
6112-
`/jquery/1.2.0/jquery.min.js`.
6115+
`org.webjars:webjars-locator-core` library is present on the classpath, at the cost of a
6116+
classpath scanning that could slow down application startup. The resolver can re-write URLs to
6117+
include the version of the jar and can also match against incoming URLs without versions
6118+
-- for example, from `/webjars/jquery/jquery.min.js` to `/webjars/jquery/1.2.0/jquery.min.js`.
61136119

61146120
TIP: The Java configuration based on `ResourceHandlerRegistry` provides further options
61156121
for fine-grained control, e.g. last-modified behavior and optimized resource resolution.

0 commit comments

Comments
 (0)