Class PathPattern

org.springframework.web.util.pattern

PathPattern matches URL paths rules

  • ? — matches one character
  • - — matches zero or more characters within a path segment
  • ** — matches zero or more path segments until the end of the path
  • {spring} — matches a path segment and captures it as a variable named “spring”
  • {spring:[a-z]+} — matches the regexp [a-z]+ as a path variable named “spring”
  • {_spring} — matches zero or more path segments until the end of the path and captures it as a variable named “spring”

Examples

  • /pages/t?st.html — matches /pages/test.html but also /pages/tast.html but not /pages/toast.html
  • /resources/_.png — matches all .png files in the resources directory
  • /resources/** — matches all files underneath the /resources/ path, including /resources/image.png and /resources/css/spring.css
  • /resources/{*path} — matches all files underneath the /resources/ path and captures their relative path in a variable named “path”; /resources/image.png will match with “spring” -> “/image.png”, and /resources/css/spring.css will match with “spring” -> “/css/spring.css”
  • /resources/{filename:\w+}.dat — matches /resources/spring.dat and assign the value “spring” to the filename variable

  spring
Your browser is out-of-date!

Update your browser to view this website correctly. Update my browser now

×