Use undecoded path for request mapping in WebFlux [SPR-15640] #20199
Labels
in: web
Issues in web modules (web, webmvc, webflux, websocket)
type: enhancement
A general enhancement
Milestone
Rossen Stoyanchev opened SPR-15640 and commented
Status Quo
By default Spring MVC decodes the path before using it for request mapping purposes. In turn that means
@RequestMapping
patterns can be expressed in undecoded form. This works just fine until the path contains encoded characters with reserved URI meaning such as a "/" or ";" where decoding alters the structure of the path. Applications can configure aUrlPathHelper
that does not decode the URL path which works fine and in that case URI variables are automatically decoded before being injected into a controller with@PathVariable
. However the literal parts of mapping patterns must now be expressed with encoded characters.WebFlux
In WebFlux the URL path will not be decoded for request mapping purposes. Patterns can still be expressed in undecoded form but will be encoded as UTF-8 and stored that way to match to the encoded URL path of incoming requests. This eliminates the need to specify whether the path should be decoded or not along exposure to issues that can arise from decoding the path.
Spring MVC
Since support for encoding patterns will likely be in the new
PathPatternParser
- used by default in WebFlux, this will be a natural fit for WebFlux. The goal for Spring MVC is for applications to be able to achieve the same affect by switching to use thePathPatternParser
.Sub-tasks:
Issue Links:
The text was updated successfully, but these errors were encountered: