Add support for customizing WebJars resource handler path pattern
At present, both Spring MVC and Spring WebFlux auto-configurations hardcode the path pattern for WebJars resource handlers to "/webjars/**", which means users are unable to change the path. This commit introduces "spring.mvc.webjars-path-pattern" and "spring.webflux.webjars-path-pattern" configuration properties that allow customization of WebJars resource handler path pattern. See gh-31769
This commit is contained in:
committed by
Stephane Nicoll
parent
ec63a981d0
commit
94f42d11e5
@@ -84,7 +84,8 @@ If you do so, the default welcome page detection switches to your custom locatio
|
||||
So, if there is an `index.html` in any of your locations on startup, it is the home page of the application.
|
||||
|
||||
In addition to the "`standard`" static resource locations listed earlier, a special case is made for https://www.webjars.org/[Webjars content].
|
||||
Any resources with a path in `+/webjars/**+` are served from jar files if they are packaged in the Webjars format.
|
||||
By default, any resources with a path in `+/webjars/**+` are served from jar files if they are packaged in the Webjars format.
|
||||
The path can be customized with the configprop:spring.webflux.webjars-path-pattern[] property.
|
||||
|
||||
TIP: Spring WebFlux applications do not strictly depend on the servlet API, so they cannot be deployed as war files and do not use the `src/main/webapp` directory.
|
||||
|
||||
|
||||
@@ -107,7 +107,8 @@ You can also customize the static resource locations by using the configprop:spr
|
||||
The root servlet context path, `"/"`, is automatically added as a location as well.
|
||||
|
||||
In addition to the "`standard`" static resource locations mentioned earlier, a special case is made for https://www.webjars.org/[Webjars content].
|
||||
Any resources with a path in `+/webjars/**+` are served from jar files if they are packaged in the Webjars format.
|
||||
By default, any resources with a path in `+/webjars/**+` are served from jar files if they are packaged in the Webjars format.
|
||||
The path can be customized with the configprop:spring.mvc.webjars-path-pattern[] property.
|
||||
|
||||
TIP: Do not use the `src/main/webapp` directory if your application is packaged as a jar.
|
||||
Although this directory is a common standard, it works *only* with war packaging, and it is silently ignored by most build tools if you generate a jar.
|
||||
|
||||
Reference in New Issue
Block a user