springboot的PathVariable接收参数值带点号问题

问题

 @RequestMapping(value = "/{version}",method = RequestMethod.GET)
    public String demo(@PathVariable String version){
       return version;
    }

如果version是1.0.0,则返回1.0,这俨然不是我们所期望的。

解决

@RequestMapping(value = "/{version:.+}",method = RequestMethod.GET)
    public String demo(@PathVariable String version){
       return version;
    }

doc

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

想获取最新内容,请关注微信公众号

springboot的PathVariable接收参数值带点号问题_第1张图片
qrcode_for_gh_121b87c80448_258.jpg

你可能感兴趣的:(springboot的PathVariable接收参数值带点号问题)