蚂蚁路径样式图案 [英] Ant path style patterns

查看:25
本文介绍了蚂蚁路径样式图案的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Ant 路径样式模式的规则是什么.

Ant 网站本身的信息量惊人.

The Ant site itself is surprisingly uninformative.

推荐答案

Ant-style path patterns matching in :

Ant-style path patterns matching in spring-framework:

映射使用以下规则匹配 URL:

The mapping matches URLs using the following rules:

  • ? 匹配一个字符
  • * 匹配零个或多个字符
  • ** 匹配路径中的零个或多个目录"
  • {spring:[a-z]+} 匹配正则表达式 [a-z]+ 作为名为spring"的路径变量
  • ? matches one character
  • * matches zero or more characters
  • ** matches zero or more 'directories' in a path
  • {spring:[a-z]+} matches the regexp [a-z]+ as a path variable named "spring"

一些例子:

  • com/t?st.jsp - 匹配 com/test.jsp 但也匹配 com/tast.jspcom/txst.jsp
  • com/*.jsp - 匹配 com 目录中的所有 .jsp 文件
  • com/**/test.jsp - 匹配 com 路径下的所有 test.jsp 文件
  • org/springframework/**/*.jsp - 匹配 org/springframework 路径
  • 下的所有 .jsp 文件
  • org/**/servlet/bla.jsp - 匹配 org/springframework/servlet/bla.jsp 但也匹配 org/springframework/testing/servlet/bla.jsporg/servlet/bla.jsp
  • com/{filename:\\w+}.jsp 将匹配 com/test.jsp 并将值 test 分配给 <代码>文件名变量
  • com/t?st.jsp - matches com/test.jsp but also com/tast.jsp or com/txst.jsp
  • com/*.jsp - matches all .jsp files in the com directory
  • com/**/test.jsp - matches all test.jsp files underneath the com path
  • org/springframework/**/*.jsp - matches all .jsp files underneath the org/springframework path
  • org/**/servlet/bla.jsp - matches org/springframework/servlet/bla.jsp but also org/springframework/testing/servlet/bla.jsp and org/servlet/bla.jsp
  • com/{filename:\\w+}.jsp will match com/test.jsp and assign the value test to the filename variable

http://docs.spring.io/spring/docs/current/javadoc-api/org/springframework/util/AntPathMatcher.html

这篇关于蚂蚁路径样式图案的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆