@Override public Resource[] getResources(String locationPattern) throws IOException { //非空校验 Assert.notNull(locationPattern, "Location pattern must not be null"); //如果locationPattern以"classpath*:"开头 if (locationPattern.startsWith(CLASSPATH_ALL_URL_PREFIX)) { // a class path resource (multiple resources for same name possible) //路径包含通配符,AntPathMatcher if (getPathMatcher().isPattern(locationPattern.substring(CLASSPATH_ALL_URL_PREFIX.length()))) { // a class path resource pattern //则通过Resource[] findPathMatchingResources(String locationPattern)方式解析 return findPathMatchingResources(locationPattern); } else { //不包含通配符则 Resource[] findAllClassPathResources(String location) 方法解析 // all class path resources with the given name return findAllClassPathResources(locationPattern.substring(CLASSPATH_ALL_URL_PREFIX.length())); } } else { // Generally only look for a pattern after a prefix here, // and on Tomcat only after the "*/" separator for its "war:" protocol. intprefixEnd= (locationPattern.startsWith("war:") ? locationPattern.indexOf("*/") + 1 : locationPattern.indexOf(':') + 1); if (getPathMatcher().isPattern(locationPattern.substring(prefixEnd))) { // a file pattern //有通配符 return findPathMatchingResources(locationPattern); } else { // a single resource with the given name //单个资源 returnnewResource[] {getResourceLoader().getResource(locationPattern)}; } } }