|
|
@ -27,6 +27,7 @@ import java.util.ArrayList; |
|
|
|
import java.util.Arrays; |
|
|
|
import java.util.Arrays; |
|
|
|
import java.util.Collections; |
|
|
|
import java.util.Collections; |
|
|
|
import java.util.Comparator; |
|
|
|
import java.util.Comparator; |
|
|
|
|
|
|
|
import java.util.HashMap; |
|
|
|
import java.util.LinkedHashMap; |
|
|
|
import java.util.LinkedHashMap; |
|
|
|
import java.util.LinkedHashSet; |
|
|
|
import java.util.LinkedHashSet; |
|
|
|
import java.util.List; |
|
|
|
import java.util.List; |
|
|
@ -116,6 +117,7 @@ import org.springframework.web.servlet.mvc.multiaction.MethodNameResolver; |
|
|
|
import org.springframework.web.servlet.mvc.multiaction.NoSuchRequestHandlingMethodException; |
|
|
|
import org.springframework.web.servlet.mvc.multiaction.NoSuchRequestHandlingMethodException; |
|
|
|
import org.springframework.web.servlet.support.RequestContextUtils; |
|
|
|
import org.springframework.web.servlet.support.RequestContextUtils; |
|
|
|
import org.springframework.web.servlet.support.WebContentGenerator; |
|
|
|
import org.springframework.web.servlet.support.WebContentGenerator; |
|
|
|
|
|
|
|
import org.springframework.web.util.UriTemplate; |
|
|
|
import org.springframework.web.util.UrlPathHelper; |
|
|
|
import org.springframework.web.util.UrlPathHelper; |
|
|
|
import org.springframework.web.util.WebUtils; |
|
|
|
import org.springframework.web.util.WebUtils; |
|
|
|
|
|
|
|
|
|
|
@ -587,7 +589,7 @@ public class AnnotationMethodHandlerAdapter extends WebContentGenerator |
|
|
|
if (!typeLevelPattern.startsWith("/")) { |
|
|
|
if (!typeLevelPattern.startsWith("/")) { |
|
|
|
typeLevelPattern = "/" + typeLevelPattern; |
|
|
|
typeLevelPattern = "/" + typeLevelPattern; |
|
|
|
} |
|
|
|
} |
|
|
|
if (isPathMatchInternal(typeLevelPattern, lookupPath)) { |
|
|
|
if (getMatchingPattern(typeLevelPattern, lookupPath) != null) { |
|
|
|
if (mappingInfo.matches(request)) { |
|
|
|
if (mappingInfo.matches(request)) { |
|
|
|
match = true; |
|
|
|
match = true; |
|
|
|
mappingInfo.addMatchedPattern(typeLevelPattern); |
|
|
|
mappingInfo.addMatchedPattern(typeLevelPattern); |
|
|
@ -695,8 +697,9 @@ public class AnnotationMethodHandlerAdapter extends WebContentGenerator |
|
|
|
typeLevelPattern = "/" + typeLevelPattern; |
|
|
|
typeLevelPattern = "/" + typeLevelPattern; |
|
|
|
} |
|
|
|
} |
|
|
|
String combinedPattern = pathMatcher.combine(typeLevelPattern, methodLevelPattern); |
|
|
|
String combinedPattern = pathMatcher.combine(typeLevelPattern, methodLevelPattern); |
|
|
|
if (isPathMatchInternal(combinedPattern, lookupPath)) { |
|
|
|
String matchingPattern = getMatchingPattern(combinedPattern, lookupPath); |
|
|
|
return combinedPattern; |
|
|
|
if (matchingPattern != null) { |
|
|
|
|
|
|
|
return matchingPattern; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
return null; |
|
|
|
return null; |
|
|
@ -704,30 +707,30 @@ public class AnnotationMethodHandlerAdapter extends WebContentGenerator |
|
|
|
String bestMatchingPattern = (String) request.getAttribute(HandlerMapping.BEST_MATCHING_PATTERN_ATTRIBUTE); |
|
|
|
String bestMatchingPattern = (String) request.getAttribute(HandlerMapping.BEST_MATCHING_PATTERN_ATTRIBUTE); |
|
|
|
if (StringUtils.hasText(bestMatchingPattern) && bestMatchingPattern.endsWith("*")) { |
|
|
|
if (StringUtils.hasText(bestMatchingPattern) && bestMatchingPattern.endsWith("*")) { |
|
|
|
String combinedPattern = pathMatcher.combine(bestMatchingPattern, methodLevelPattern); |
|
|
|
String combinedPattern = pathMatcher.combine(bestMatchingPattern, methodLevelPattern); |
|
|
|
if (!combinedPattern.equals(bestMatchingPattern) && |
|
|
|
String matchingPattern = getMatchingPattern(combinedPattern, lookupPath); |
|
|
|
(isPathMatchInternal(combinedPattern, lookupPath))) { |
|
|
|
if ((matchingPattern != null) && !matchingPattern.equals(bestMatchingPattern)) { |
|
|
|
return combinedPattern; |
|
|
|
return matchingPattern; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
if (isPathMatchInternal(methodLevelPattern, lookupPath)) { |
|
|
|
return getMatchingPattern(methodLevelPattern, lookupPath); |
|
|
|
return methodLevelPattern; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return null; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private boolean isPathMatchInternal(String pattern, String lookupPath) { |
|
|
|
private String getMatchingPattern(String pattern, String lookupPath) { |
|
|
|
if (pattern.equals(lookupPath) || pathMatcher.match(pattern, lookupPath)) { |
|
|
|
if (pattern.equals(lookupPath)) { |
|
|
|
return true; |
|
|
|
return pattern; |
|
|
|
} |
|
|
|
} |
|
|
|
boolean hasSuffix = pattern.indexOf('.') != -1; |
|
|
|
boolean hasSuffix = pattern.indexOf('.') != -1; |
|
|
|
if (!hasSuffix && pathMatcher.match(pattern + ".*", lookupPath)) { |
|
|
|
if (!hasSuffix && pathMatcher.match(pattern + ".*", lookupPath)) { |
|
|
|
return true; |
|
|
|
return pattern + ".*"; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (pathMatcher.match(pattern, lookupPath)) { |
|
|
|
|
|
|
|
return pattern; |
|
|
|
} |
|
|
|
} |
|
|
|
boolean endsWithSlash = pattern.endsWith("/"); |
|
|
|
boolean endsWithSlash = pattern.endsWith("/"); |
|
|
|
if (!endsWithSlash && pathMatcher.match(pattern + "/", lookupPath)) { |
|
|
|
if (!endsWithSlash && pathMatcher.match(pattern + "/", lookupPath)) { |
|
|
|
return true; |
|
|
|
return pattern + "/"; |
|
|
|
} |
|
|
|
} |
|
|
|
return false; |
|
|
|
return null; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@SuppressWarnings("unchecked") |
|
|
|
@SuppressWarnings("unchecked") |
|
|
|