Has problems after @PathVariable parameter value containing the '/' character,with Spring MVC

后端 未结 2 1282
广开言路
广开言路 2020-12-22 10:18

I have a use case. Spring MVC REST Url receive content using the GET method code is as follows:

@RequestMapping(\"/q/{key}\")
public String query(@PathVariab         


        
2条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-22 10:44

    You can include regular expressions in your path variable as such:

    @RequestMapping("/q/{key:.*}")
    

    This will grab EVERYTHING after the /q/. Or you can make it a more specific regex to match the pattern you are actually expecting.

提交回复
热议问题