Ant 路径样式模式的规则是什么。
Ant 站点本身的信息量出奇地少。
Ant 路径样式模式的规则是什么。
Ant 站点本身的信息量出奇地少。
我想你的意思是如何使用路径模式
如果是关于使用斜杠还是反斜杠,这些将被转换为执行时使用的平台上的路径分隔符。
该实用程序使用三种不同的通配符。
+----------+-----------------------------------+
| Wildcard | Description |
+----------+-----------------------------------+
| * | Matches zero or more characters. |
| ? | Matches exactly one character. |
| ** | Matches zero or more directories. |
+----------+-----------------------------------+
通过@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 |
+------------------------------+--------------------------------------------------------+
正如@user11153 提到的,Spring 的AntPathMatcher实现并记录了 Ant 样式路径模式匹配的基础知识。
此外,Java 7 的 nio API 通过FileSystem.getPathMatcher添加了一些对基本模式匹配的内置支持
Ant 风格的路径模式匹配 弹簧框架:
http://docs.spring.io/spring/docs/current/javadoc-api/org/springframework/util/AntPathMatcher.html