You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: spring-boot-project/spring-boot-docs/src/docs/asciidoc/web/servlet.adoc
+8-13Lines changed: 8 additions & 13 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -255,27 +255,22 @@ Alternatively, rather than open all suffix patterns, it is more secure to only s
255
255
use-registered-suffix-pattern: true
256
256
----
257
257
258
-
As of Spring Framework 5.3, Spring MVC supports several implementation strategies for matching request paths to Controller handlers.
259
-
It was previously only supporting the `AntPathMatcher` strategy, but it now also offers `PathPatternParser`.
260
-
Spring Boot now provides a configuration property to choose and opt in the new strategy:
258
+
As of Spring Framework 5.3, Spring MVC supports two strategies for matching request paths to controllers.
259
+
By default, Spring Boot uses the `PathPatternParser` strategy.
260
+
`PathPatternParser` is an https://spring.io/blog/2020/06/30/url-matching-with-pathpattern-in-spring-mvc[optimized implementation] but comes with some restrictions compared to the `AntPathMatcher` strategy.
261
+
`PathPatternParser` restricts usage of {spring-framework-docs}/web.html#mvc-ann-requestmapping-uri-templates[some path patterns variants].
262
+
It is also incompatible with suffix pattern matching (configprop:spring.mvc.pathmatch.use-suffix-pattern[deprecated], configprop:spring.mvc.pathmatch.use-registered-suffix-pattern[deprecated]) and configuring the `DispatcherServlet` with a path prefix (configprop:spring.mvc.servlet.path[]).
263
+
264
+
The strategy can be configured using the configprop:spring.mvc.pathmatch.matching-strategy[] configuration property, as shown in the following example:
and is incompatible with suffix pattern matching (configprop:spring.mvc.pathmatch.use-suffix-pattern[deprecated],
276
-
configprop:spring.mvc.pathmatch.use-registered-suffix-pattern[deprecated]) or mapping the `DispatcherServlet`
277
-
with a servlet prefix (configprop:spring.mvc.servlet.path[]).
278
-
279
274
By default, Spring MVC will send a 404 Not Found error response if a handler is not found for a request.
280
275
To have a `NoHandlerFoundException` thrown instead, set configprop:spring.mvc.throw-exception-if-no-handler-found to `true`.
281
276
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.
0 commit comments