Optional path variables in Spring-MVC RequestMapping URITemplate

后端 未结 4 1320
暖寄归人
暖寄归人 2021-02-20 12:10

I have the following mapping:

@RequestMapping(value = \"/{first}/**/{last}\", method = RequestMethod.GET)
public String test(@PathVariable(\"first\") String firs         


        
4条回答
  •  臣服心动
    2021-02-20 12:49

    Can't be done as far as I know. Just as you stated, the regular expression is being applied to the path element after splitting up the path at each slash, so the regular expression can never match a '/'.

    You could manually inspect the url and parse it yourself from the request object.

提交回复
热议问题