Skip to content

Commit 864dfe3

Browse files
committed
Merge branch '2.7.x' into 3.0.x
Closes gh-34190
2 parents 24260cb + 595ac43 commit 864dfe3

File tree

1 file changed

+5
-0
lines changed
  • spring-boot-project/spring-boot-docs/src/docs/asciidoc/web

1 file changed

+5
-0
lines changed

spring-boot-project/spring-boot-docs/src/docs/asciidoc/web/servlet.adoc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,11 @@ https://spring.io/blog/2020/06/30/url-matching-with-pathpattern-in-spring-mvc[de
249249
NOTE: `PathPatternParser` is an optimized implementation but restricts usage of {spring-framework-docs}/web.html#mvc-ann-requestmapping-uri-templates[some path patterns variants].
250250
It is incompatible with suffix pattern matching or mapping the `DispatcherServlet` with a servlet prefix (configprop:spring.mvc.servlet.path[]).
251251

252+
By default, Spring MVC will send a 404 Not Found error response if a handler is not found for a request.
253+
To have a `NoHandlerFoundException` thrown instead, set configprop:spring.mvc.throw-exception-if-no-handler-found to `true`.
254+
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.
255+
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.
256+
252257

253258

254259
[[web.servlet.spring-mvc.binding-initializer]]

0 commit comments

Comments
 (0)