Path Pattern

Roeniss Moon·2020년 11월 30일
0

스프링 수첩

목록 보기
2/3

reference : https://docs.spring.io/spring-framework/docs/current/javadoc-api/org/springframework/web/util/pattern/PathPattern.html

RouteFunctions를 사용할 때는 PathPattern을 이용할 수 있다.

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"

*path segment : "/"로 구분되는 각각의 덩어리들

(Spring MVC에서 사용하는 것으로 추측되는) AntPathMatcher와 다르게, **{*name}은 "end of the path" 까지 한 번에 가져옴

Examples

  • /pages/t?st.html

    • /pages/test.html
    • /pages/tXst.html
    • /pages/toast.html (❌)
  • /resources/*.png

    • all .png files in the resources directory
  • /resources/**

    • all files underneath the '/resources/' path
    • /resources/image.png
    • /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, "path" → "/image.png"
    • /resources/css/spring.css, "path" → "/css/spring.css"
  • /resources/{filename:\w+}.dat

    • /resources/spring.dat, "spring" → filename
profile
기능이 아니라 버그예요

0개의 댓글