美文网首页
SpringBoot实战系列之@PathVariable

SpringBoot实战系列之@PathVariable

作者: 程序员小白成长记 | 来源:发表于2020-05-24 23:49 被阅读0次

Springboot用@PathVariable传参,最后一个参数会丢失小数点后面的部分

{objectName:.+}

如参数名为沁园春.docx
编码后为/%e6%b2%81%e5%9b%ad%e6%98%a5.docx

image.png

eg:
/%e6%b2%81%e5%9b%ad%e6%98%a5.docx

 @ResponseBody
 @RequestMapping(value = "bos/url/{objectName:.+}", method = RequestMethod.GET)
 public ResultResponse getUrl(@PathVariable String objectName) throws UnsupportedEncodingException {
        ... ...
 }

如果为bos/url/{objectName}会丢失小数点后的后缀,改为{objectName:.+}既可以不丢失

相关文章

网友评论

      本文标题:SpringBoot实战系列之@PathVariable

      本文链接:https://www.haomeiwen.com/subject/apasahtx.html