From 2cad4a7174a285aeb1f3c6d6d5185662ce37b412 Mon Sep 17 00:00:00 2001 From: Michal Domagala Date: Fri, 8 Jul 2022 23:07:25 +0200 Subject: [PATCH] Document addition config for throw-exception-if-no-handler-found See gh-31660 --- .../spring-boot-docs/src/docs/asciidoc/web/servlet.adoc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/spring-boot-project/spring-boot-docs/src/docs/asciidoc/web/servlet.adoc b/spring-boot-project/spring-boot-docs/src/docs/asciidoc/web/servlet.adoc index f6e82a88d5..755d357f1b 100644 --- a/spring-boot-project/spring-boot-docs/src/docs/asciidoc/web/servlet.adoc +++ b/spring-boot-project/spring-boot-docs/src/docs/asciidoc/web/servlet.adoc @@ -112,6 +112,8 @@ Any resources with a path in `+/webjars/**+` are served from jar files if they a 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. +TIP: If you configure `spring.mvc.throw-exception-if-no-handler-found=true`, it will not work with default `+spring.mvc.static-path-pattern=/**+`, because each url matches `+/**+`. Url without handler must be excluded from _static-path-pattern_ to `NoHandlerFoundException` be thrown. Quite effective exclusion is `spring.mvc.static-path-pattern=` + Spring Boot also supports the advanced resource handling features provided by Spring MVC, allowing use cases such as cache-busting static resources or using version agnostic URLs for Webjars. To use version agnostic URLs for Webjars, add the `webjars-locator-core` dependency.