Java Spring 中 Resources 路径若干问题

ant-style资源路径通配符

ANT通配符有三种:
Java Spring 中 Resources 路径若干问题_第1张图片
Java Spring 中 Resources 路径若干问题_第2张图片

最长匹配规则(has more characters),即越精确的模式越会被优先匹配到。例如,URL请求/app/dir/file.jsp,现在存在两个路径匹配模式/**/*.jsp/app/dir/*.jsp,那么会根据模式/app/dir/*.jsp来匹配。

Resource路径strings

Java Spring 中 Resources 路径若干问题_第3张图片
一些ant风格资源路径示例:

/WEB-INF/-context.xml
com/mycompany/**/applicationContext.xml
file:C:/some/path/
-context.xml
classpath:com/mycompany/**/applicationContext.xml

classpath*: 与 classpath: 通配符

当使用 ‘classpath:’ 加上 Ant 风格的通配符时, Spring查找的是 classpath 匹配的第一个目录。
使用 ‘classpath*:’ 前缀会让资源加载器(resource loader) 扫描 classpath 中的所有匹配的目录。

你可能感兴趣的:(Java,java,spring,servlet)