Spring MVC @PathVariable with dot (.) is getting truncated

后端 未结 17 1543
被撕碎了的回忆
被撕碎了的回忆 2020-11-22 06:00

This is continuation of question Spring MVC @PathVariable getting truncated

Spring forum states that it has fixed(3.2 version) as part of ContentNegotiationManager.

17条回答
  •  没有蜡笔的小新
    2020-11-22 06:45

    For me the

    @GetMapping(path = "/a/{variableName:.+}")
    

    does work but only if you also encode the "dot" in your request url as "%2E" then it works. But requires URL's to all be that...which is not a "standard" encoding, though valid. Feels like something of a bug :|

    The other work around, similar to the "trailing slash" way is to move the variable that will have the dot "inline" ex:

    @GetMapping(path = "/{variableName}/a")

    now all dots will be preserved, no modifications needed.

提交回复
热议问题