Regex in spring controller

后端 未结 2 1995
误落风尘
误落风尘 2020-12-09 08:53

I am trying to build a request filter that will only get used if it matches a pattern of the letter e, then a number. However I cannot seem to get it to work. I keep gettin

2条回答
  •  生来不讨喜
    2020-12-09 09:15

    According to the documentation, you have to use something like {varName:regex}. There's even an example :

    @RequestMapping("/spring-web/{symbolicName:[a-z-]+}-{version:\\d\\.\\d\\.\\d}{extension:\\.[a-z]+}")
      public void handle(@PathVariable String version, @PathVariable String extension) {
        // ...
      }
    }
    

提交回复
热议问题