Merge pull request #31660 from michaldo

* gh-31660:
  Polish "Document addition config for throw-exception-if-no-handler-found"
  Document addition config for throw-exception-if-no-handler-found

Closes gh-31660
This commit is contained in:
Andy Wilkinson 2023-02-14 21:05:09 +00:00
commit 595ac4398c

View File

@ -276,6 +276,11 @@ and is incompatible with suffix pattern matching (configprop:spring.mvc.pathmatc
configprop:spring.mvc.pathmatch.use-registered-suffix-pattern[deprecated]) or mapping the `DispatcherServlet`
with a servlet prefix (configprop:spring.mvc.servlet.path[]).
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`.
Note that, by default, the <<web#web.servlet.spring-mvc.static-content, serving of static content>> 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.
[[web.servlet.spring-mvc.binding-initializer]]