From f8130791ea92c68dd73a9b69f1abbd18fdb6f7a8 Mon Sep 17 00:00:00 2001 From: Andy Wilkinson Date: Fri, 6 Sep 2024 10:17:20 +0100 Subject: [PATCH] Update docs to reflect new no handler found exception behavior Closes gh-42164 --- .../spring-boot-docs/src/docs/asciidoc/web/servlet.adoc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) 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 0b63e82d3f1a..1c4f6219b3aa 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 @@ -285,10 +285,10 @@ The strategy can be configured using the configprop:spring.mvc.pathmatch.matchin matching-strategy: "ant-path-matcher" ---- -By default, Spring MVC will send a 404 Not Found error response if a handler is not found for a request. -To have a `NoHandlerFoundException` thrown instead, set configprop:spring.mvc.throw-exception-if-no-handler-found to `true`. +Spring MVC will throw a `NoHandlerFoundException` if a handler is not found for a request. Note that, by default, the <> is mapped to `+/**+` and will, therefore, provide a handler for all requests. -For a `NoHandlerFoundException` to be thrown, you must also set configprop:spring.mvc.static-path-pattern[] to a more specific value such as `/resources/**` or set configprop:spring.web.resources.add-mappings[] to `false` to disable serving of static content entirely. +If no static content is available, `ResourceHttpRequestHandler` will throw a `NoResourceFoundException`. +For a `NoHandlerFoundException` to be thrown, set configprop:spring.mvc.static-path-pattern[] to a more specific value such as `/resources/**` or set configprop:spring.web.resources.add-mappings[] to `false` to disable serving of static content entirely.