spring-framework icon indicating copy to clipboard operation
spring-framework copied to clipboard

Create Filter to handle URLs with trailing slashes

Open rstoyanchev opened this issue 8 months ago • 1 comments

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 like UrlRewriteFilter. This can be configurable by URL pattern or for all requests. Another suggestion from https://github.com/spring-projects/spring-framework/issues/28552#issuecomment-1469740759 is to log URLs with a trailing slash in order to discover and phase them out.

rstoyanchev avatar Oct 05 '23 12:10 rstoyanchev

why does'n support trailing slash by default same as version before ?

thammaratNak1 avatar May 09 '24 04:05 thammaratNak1

Hi, there any news for this Filter built-in solution? On my company we migrated to SpringBoot 3 and found the 404 problem from the deprecation of trailing slash.

Have a good one, God bless you.

SebasAnasco1517 avatar May 15 '24 12:05 SebasAnasco1517

@SebasAnasco1517 Workaround is setUseTrailingSlashMatch. I'm using it in several projects

https://github.com/spring-projects/spring-framework/issues/28552#issuecomment-1746252506

ericdriggs avatar May 15 '24 16:05 ericdriggs

I've added UrlHandlerFilter in edb6bb717d9ea10429a9e5c1fba285cd7761d5a1 that will be in 6.2.0 snapshots shortly, and in the M2 release tomorrow. Early feedback towards further 6.2 milestones would be much appreciated!

There is no WebFlux equivalent yet, but I've created #32830 for M3 to keep track of that.

rstoyanchev avatar May 15 '24 17:05 rstoyanchev