-
Notifications
You must be signed in to change notification settings - Fork 38.5k
Create Filter to handle URLs with trailing slashes #31366
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
why does'n support trailing slash by default same as version before ? |
Hi, Have a good one, God bless you. |
@SebasAnasco1517 |
@rstoyanchev can you please also tell how to use this? Do you have any documentation or Blog post for this? |
@kundan621 we've added some documentation for this. See https://docs.spring.io/spring-framework/reference/6.2-SNAPSHOT/web/webmvc/filters.html#filters.url-handler |
Hi, @rstoyanchev, What if you need to filter into the other direction, as if the user does not have the trailing slash added but the endpoint expects it? In our case we use openapi to generate endpoint interfaces, and the root of our endpoint is "/" and that leads to endpoints defined as with just the trailing slash after the context path. your filter is removing it, but we need to have it added in the filter if the user does not add it. |
@SchlauFuchs is this just for the contextPath? Please, create a new issue and provide details. |
Matching URLs with a trailing slash was deprecated in 6.0 in favor of early handling via proxy or
Filter
like UrlRewriteFilter, see #28552 for details. The continued feedback on the issue, however, makes it clear we need to go further and provide built-in support.This can be a
Filter
ordered as early as possible, e.g. ahead of security, that handles URLs with a trailing slash. One option is a permanent redirect, and another is to rewrite the request likeUrlRewriteFilter
. This can be configurable by URL pattern or for all requests. Another suggestion from #28552 (comment) is to log URLs with a trailing slash in order to discover and phase them out.The text was updated successfully, but these errors were encountered: