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

后端 未结 17 1336
被撕碎了的回忆
被撕碎了的回忆 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:53

    adding the ":.+" worked for me, but not until I removed outer curly brackets.

    value = {"/username/{id:.+}"} didn't work

    value = "/username/{id:.+}" works

    Hope I helped someone :)

    0 讨论(0)
  • 2020-11-22 06:54

    If you write both back and frontend, another simple solution is to attach a "/" at the end of the URL at front. If so, you don't need to change your backend...

    somepath/myemail@gmail.com/
    

    Be happy!

    0 讨论(0)
  • 2020-11-22 06:56

    In Spring Boot Rest Controller, I have resolved these by following Steps:

    RestController :

    @GetMapping("/statusByEmail/{email:.+}/")
    public String statusByEmail(@PathVariable(value = "email") String email){
      //code
    }
    

    And From Rest Client:

    Get http://mywebhook.com/statusByEmail/abc.test@gmail.com/
    
    0 讨论(0)
  • 2020-11-22 06:56

    /somepath/{variable:.+} works in Java requestMapping tag.

    0 讨论(0)
  • 2020-11-22 06:56

    In Spring Boot, The Regular expression solve the problem like

    @GetMapping("/path/{param1:.+}")
    
    0 讨论(0)
提交回复
热议问题