ANT通配符有三种:
通配符 | 说明 |
---|---|
? | 匹配任何单字符 |
* | 匹配0或者任意数量的字符(不包含 /) |
** | 匹配0或者更多的目录(可能包含 /) |
例子:
URL路径 | 说明 |
---|---|
/app/*.x | 匹配所有在app路径下的.x文件 |
/app/p?ttern | 匹配 /app/pattern 和 /app/pXttern, 但是不包括/app/pttern |
/**/example | 匹配 /app/example, /app/foo/example, 和 /example |
/app/**/dir/file.* | 匹配 /app/dir/file.jsp, /app/foo/dir/file.html,/app/foo/bar/dir/file.pdf, 和 /app/dir/file.java |
/**/*.jsp | 匹配任何的.jsp 文件 |
需要注意的是,路径匹配遵循最长匹配原则(has more characters),例如 /app/dir/file.jsp
符合/**/*.jsp
和 /app/dir/*.jsp
两个路径模式,那么最终就是根据后者来匹配。