0

Referring to Spring catch all route for index.html, I am trying out the regex "/**/{spring:\\w+}"to catch all routes. But I get the error:

Tokenizing Error: java.util.regex.PatternSyntaxException, dangling metacharacter '*' at Index 2

When I fix this by "/\\*\\*/{spring:\\w+}", my regex fails to catch routes.

Requesting guidance regarding the same.

Toto
  • 89,455
  • 62
  • 89
  • 125
Kate
  • 21
  • 2

1 Answers1

0

As mentioned in the documentation of the method:

Patterns like "/static/**" or "/css/{filename:\w+\.css}" are allowed. See AntPathMatcher for more details on the syntax.

See AntPathMatcher. I assume "/**/{spring:\\w+}" needs to be changed at least to "/**/{spring:\w+}"

Malte Jacobson
  • 215
  • 1
  • 11
  • You are right. But at least this matches: ```java boolean b = new AntPathMatcher().match("/**/{spring:\\w+}", "/foo/bar"); Assertions.assertTrue(b); ``` – Malte Jacobson Aug 13 '20 at 13:34