반응형
개미 경로 스타일 패턴
개미 경로 스타일 패턴의 규칙은 무엇입니까?
개미 사이트 자체는 놀라울 정도로 유익하지 않다.
스프링 프레임에서 일치하는 개미 스타일의 경로 패턴:
매핑은 다음 규칙을 사용하여 URL과 일치합니다.
?
1개의 문자와 일치합니다.*
0자 이상의 문자와 일치합니다.**
경로에서 0개 이상의 '디렉토리'와 일치합니다.{spring:[a-z]+}
regexp와 일치합니다.[a-z]+
"스프링"이라는 경로 변수로써몇 가지 예:
com/t?st.jsp
- com/test.jsp와 일치하지만,com/tast.jsp
또는com/txst.jsp
com/*.jsp
- 모두 일치.jsp
의 파일com
디렉토리com/**/test.jsp
- 모두 일치test.jsp
아래 파일com
경로.org/springframework/**/*.jsp
- 모두 일치.jsp
아래 파일org/springframework path
org/**/servlet/bla.jsp
(일치)org/springframework/servlet/bla.jsp
하지만 또한org/springframework/testing/servlet/bla.jsp
그리고.org/servlet/bla.jsp
com/{filename:\\w+}.jsp
일치하다com/test.jsp
값을 할당합니다.test
에게filename
변수
http://docs.spring.io/spring/docs/current/javadoc-api/org/springframework/util/AntPathMatcher.html
슬래시를 사용할지 백슬래시를 사용할지에 관한 경우 실행 시 사용되는 플랫폼의 경로 구분자로 변환됩니다.
가장 높은 투표율 응답자@user11153
보다 읽기 쉬운 형식으로 표를 사용합니다.
매핑은 다음 규칙을 사용하여 URL과 일치합니다.
+-----------------+---------------------------------------------------------+
| Wildcard | Description |
+-----------------+---------------------------------------------------------+
| ? | Matches exactly one character. |
| * | Matches zero or more characters. |
| ** | Matches zero or more 'directories' in a path |
| {spring:[a-z]+} | Matches regExp [a-z]+ as a path variable named "spring" |
+-----------------+---------------------------------------------------------+
몇 가지 예:
+------------------------------+--------------------------------------------------------+
| Example | Matches: |
+------------------------------+--------------------------------------------------------+
| com/t?st.jsp | com/test.jsp but also com/tast.jsp or com/txst.jsp |
| com/*.jsp | All .jsp files in the com directory |
| com/**/test.jsp | All test.jsp files underneath the com path |
| org/springframework/**/*.jsp | All .jsp files underneath the org/springframework path |
| org/**/servlet/bla.jsp | org/springframework/servlet/bla.jsp |
| also: | org/springframework/testing/servlet/bla.jsp |
| also: | org/servlet/bla.jsp |
| com/{filename:\\w+}.jsp | com/test.jsp & assign value test to filename variable |
+------------------------------+--------------------------------------------------------+
와일드카드
유틸리티는 3개의 다른 와일드카드를 사용합니다.
+----------+-----------------------------------+
| Wildcard | Description |
+----------+-----------------------------------+
| * | Matches zero or more characters. |
| ? | Matches exactly one character. |
| ** | Matches zero or more directories. |
+----------+-----------------------------------+
@user11153에서 언급했듯이 Spring의 AntPathMatcher는 Ant-style 경로 패턴 매칭의 기본을 구현하고 문서화합니다.
또한 Java 7의 nio API는 FileSystem.getPathMatcher를 통해 기본 패턴 매칭을 지원하는 기능을 추가했습니다.
언급URL : https://stackoverflow.com/questions/2952196/ant-path-style-patterns
반응형
'programing' 카테고리의 다른 글
router-view 내의 모든 루트의 단일 루트인스톨에서의 킵얼라이브 (0) | 2022.09.13 |
---|---|
위조 방지 토큰 액시오스 ASP.넷코어 (0) | 2022.09.13 |
MariaDB는 비대칭 키 암호화를 제공합니까? (0) | 2022.09.13 |
공백을 밑줄로 바꾸기 (0) | 2022.09.13 |
-m 스위치의 용도는 무엇입니까? (0) | 2022.09.13 |