programing

개미 경로 스타일 패턴

randomtip 2022. 9. 13. 21:52
반응형

개미 경로 스타일 패턴

개미 경로 스타일 패턴의 규칙은 무엇입니까?

개미 사이트 자체는 놀라울 정도로 유익하지 않다.

스프링 에서 일치하는 개미 스타일의 경로 패턴:

매핑은 다음 규칙을 사용하여 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  |
+------------------------------+--------------------------------------------------------+

ANT 스타일 패턴 매처

와일드카드

유틸리티는 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

반응형