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
Servlet filters can be configured in the `web.xml` configuration file or using Servlet annotations.
15
+
If you are using Spring Boot, you can
16
+
{spring-boot-docs}/how-to/webserver.html#howto.webserver.add-servlet-filter-listener.spring-bean[declare them as beans and configure them as part of your application].
13
17
14
18
15
19
[[filters-http-put]]
@@ -109,4 +113,22 @@ See the sections on xref:web/webmvc-cors.adoc[CORS] and the xref:web/webmvc-cors
109
113
110
114
111
115
116
+
[[filters.url-handler]]
117
+
== URL Handler
118
+
[.small]#xref:web/webflux/reactive-spring.adoc#filters.url-handler[See equivalent in the Reactive stack]#
119
+
120
+
In previous Spring Framework versions, Spring MVC could be configured to ignore trailing slashes in URL paths
121
+
when mapping incoming requests on controller methods. This could be done by enabling the `setUseTrailingSlashMatch`
122
+
option on the `PathMatchConfigurer`. This means that sending a "GET /home/" request would be handled by a controller
123
+
method annotated with `@GetMapping("/home")`.
124
+
125
+
This option has been retired, but applications are still expected to handle such requests in a safe way.
126
+
The `UrlHandlerFilter` Servlet filter has been designed for this purpose. It can be configured to:
127
+
128
+
* respond with an HTTP redirect status when receiving URLs with trailing slashes, sending browsers to the non-trailing slash URL variant.
129
+
* wrap the request to act as if the request was sent without a trailing slash and continue the processing of the request.
130
+
131
+
Here is how you can instantiate and configure a `UrlHandlerFilter` for a blog application:
0 commit comments