List<HandlerMethod> handlerMethods = null; for (RequestMappingInfoHandlerMapping mapping : map.values()) { handlerMethods = mapping.getHandlerMethodsForMappingName(name); if (handlerMethods != null) { break;
uriVariables = getPathMatcher().extractUriTemplateVariables(bestPattern, lookupPath); if (isMatrixVariableContentAvailable()) { Map<String, MultiValueMap<String, String>> matrixVars = extractMatrixVariables(request, uriVariables); request.setAttribute(HandlerMapping.MATRIX_VARIABLES_ATTRIBUTE, matrixVars); Map<String, String> decodedUriVariables = getUrlPathHelper().decodePathVariables(request, uriVariables); request.setAttribute(HandlerMapping.URI_TEMPLATE_VARIABLES_ATTRIBUTE, decodedUriVariables);
protected RequestMappingInfoHandlerMapping() { setHandlerMethodMappingNamingStrategy(new RequestMappingInfoHandlerMethodMappingNamingStrategy()); }
private boolean isMatrixVariableContentAvailable() { return !getUrlPathHelper().shouldRemoveSemicolonContent(); }
@Override public void afterPropertiesSet() { this.config = new RequestMappingInfo.BuilderConfiguration(); this.config.setUrlPathHelper(getUrlPathHelper()); this.config.setPathMatcher(getPathMatcher()); this.config.setSuffixPatternMatch(this.useSuffixPatternMatch); this.config.setTrailingSlashMatch(this.useTrailingSlashMatch); this.config.setRegisteredSuffixPatternMatch(this.useRegisteredSuffixPatternMatch); this.config.setContentNegotiationManager(getContentNegotiationManager()); super.afterPropertiesSet(); }
@Override public List<DispatcherServletMappingDescription> describe( RequestMappingInfoHandlerMapping handlerMapping) { Map<RequestMappingInfo, HandlerMethod> handlerMethods = handlerMapping .getHandlerMethods(); return handlerMethods.entrySet().stream().map(this::describe) .collect(Collectors.toList()); }
private Map<String, MultiValueMap<String, String>> extractMatrixVariables( HttpServletRequest request, Map<String, String> uriVariables) { Map<String, MultiValueMap<String, String>> result = new LinkedHashMap<>(); uriVariables.forEach((uriVarKey, uriVarValue) -> { int equalsIndex = uriVarValue.indexOf('='); if (equalsIndex == -1) { return; } int semicolonIndex = uriVarValue.indexOf(';'); if (semicolonIndex != -1 && semicolonIndex != 0) { uriVariables.put(uriVarKey, uriVarValue.substring(0, semicolonIndex)); } String matrixVariables; if (semicolonIndex == -1 || semicolonIndex == 0 || equalsIndex < semicolonIndex) { matrixVariables = uriVarValue; } else { matrixVariables = uriVarValue.substring(semicolonIndex + 1); } MultiValueMap<String, String> vars = WebUtils.parseMatrixVariables(matrixVariables); result.put(uriVarKey, getUrlPathHelper().decodeMatrixVariables(request, vars)); }); return result; }
@Override public void afterPropertiesSet() { this.config = new RequestMappingInfo.BuilderConfiguration(); this.config.setUrlPathHelper(getUrlPathHelper()); this.config.setPathMatcher(getPathMatcher()); this.config.setSuffixPatternMatch(this.useSuffixPatternMatch); this.config.setTrailingSlashMatch(this.useTrailingSlashMatch); this.config.setRegisteredSuffixPatternMatch(this.useRegisteredSuffixPatternMatch); this.config.setContentNegotiationManager(getContentNegotiationManager()); super.afterPropertiesSet(); }
private Function<? super RequestMappingInfoHandlerMapping, Iterable<Map.Entry<RequestMappingInfo, HandlerMethod>>> toMappingEntries() { return input -> input.getHandlerMethods().entrySet(); }
uriVariables = getPathMatcher().extractUriTemplateVariables(bestPattern, lookupPath); if (isMatrixVariableContentAvailable()) { Map<String, MultiValueMap<String, String>> matrixVars = extractMatrixVariables(request, uriVariables); request.setAttribute(HandlerMapping.MATRIX_VARIABLES_ATTRIBUTE, matrixVars); Map<String, String> decodedUriVariables = getUrlPathHelper().decodePathVariables(request, uriVariables); request.setAttribute(HandlerMapping.URI_TEMPLATE_VARIABLES_ATTRIBUTE, decodedUriVariables);
/** * An alternative to {@link #fromMappingName(String)} that accepts a * {@code UriComponentsBuilder} representing the base URL. This is useful * when using MvcUriComponentsBuilder outside the context of processing a * request or to apply a custom baseUrl not matching the current request. * @param builder the builder for the base URL; the builder will be cloned * and therefore not modified and may be re-used for further calls. * @param name the mapping name * @return a builder to prepare the URI String * @throws IllegalArgumentException if the mapping name is not found or * if there is no unique match * @since 4.2 */ public static MethodArgumentBuilder fromMappingName(UriComponentsBuilder builder, String name) { RequestMappingInfoHandlerMapping handlerMapping = getRequestMappingInfoHandlerMapping(); List<HandlerMethod> handlerMethods = handlerMapping.getHandlerMethodsForMappingName(name); if (handlerMethods == null) { throw new IllegalArgumentException("Mapping mappingName not found: " + name); } if (handlerMethods.size() != 1) { throw new IllegalArgumentException("No unique match for mapping mappingName " + name + ": " + handlerMethods); } HandlerMethod handlerMethod = handlerMethods.get(0); Class<?> controllerType = handlerMethod.getBeanType(); Method method = handlerMethod.getMethod(); return new MethodArgumentBuilder(builder, controllerType, method); }
private boolean isMatrixVariableContentAvailable() { return !getUrlPathHelper().shouldRemoveSemicolonContent(); }
@Override public void afterPropertiesSet() { this.config = new RequestMappingInfo.BuilderConfiguration(); this.config.setUrlPathHelper(getUrlPathHelper()); this.config.setPathMatcher(getPathMatcher()); this.config.setSuffixPatternMatch(this.useSuffixPatternMatch); this.config.setTrailingSlashMatch(this.useTrailingSlashMatch); this.config.setRegisteredSuffixPatternMatch(this.useRegisteredSuffixPatternMatch); this.config.setContentNegotiationManager(getContentNegotiationManager()); super.afterPropertiesSet(); }
protected RequestMappingInfoHandlerMapping() { setHandlerMethodMappingNamingStrategy(new RequestMappingInfoHandlerMethodMappingNamingStrategy()); }
public void fillHandler(RequestMappingInfoHandlerMapping mappingInfoHandlerMapping){ mappingInfoHandlerMapping.getHandlerMethods().entrySet() .forEach(p->requestHandlers.add(new WebRequestHandler(p.getKey(),p.getValue()))); }
uriVariables = getPathMatcher().extractUriTemplateVariables(bestPattern, lookupPath); decodedUriVariables = getUrlPathHelper().decodePathVariables(request, uriVariables); request.setAttribute(HandlerMapping.URI_TEMPLATE_VARIABLES_ATTRIBUTE, decodedUriVariables); if (isMatrixVariableContentAvailable()) { Map<String, MultiValueMap<String, String>> matrixVars = extractMatrixVariables(request, uriVariables); request.setAttribute(HandlerMapping.MATRIX_VARIABLES_ATTRIBUTE, matrixVars);
List<HandlerMethod> handlerMethods = null; for (RequestMappingInfoHandlerMapping mapping : map.values()) { handlerMethods = mapping.getHandlerMethodsForMappingName(name); if (handlerMethods != null) { break;
private Map<String, MultiValueMap<String, String>> extractMatrixVariables( HttpServletRequest request, Map<String, String> uriVariables) { Map<String, MultiValueMap<String, String>> result = new LinkedHashMap<>(); uriVariables.forEach((uriVarKey, uriVarValue) -> { int equalsIndex = uriVarValue.indexOf('='); if (equalsIndex == -1) { return; } int semicolonIndex = uriVarValue.indexOf(';'); if (semicolonIndex != -1 && semicolonIndex != 0) { uriVariables.put(uriVarKey, uriVarValue.substring(0, semicolonIndex)); } String matrixVariables; if (semicolonIndex == -1 || semicolonIndex == 0 || equalsIndex < semicolonIndex) { matrixVariables = uriVarValue; } else { matrixVariables = uriVarValue.substring(semicolonIndex + 1); } MultiValueMap<String, String> vars = WebUtils.parseMatrixVariables(matrixVariables); result.put(uriVarKey, getUrlPathHelper().decodeMatrixVariables(request, vars)); }); return result; }
protected RequestMappingInfoHandlerMapping() { setHandlerMethodMappingNamingStrategy(new RequestMappingInfoHandlerMethodMappingNamingStrategy()); }
List<HandlerMethod> handlerMethods = handlerMapping.getHandlerMethodsForMappingName(name); if (handlerMethods == null) { throw new IllegalArgumentException("Mapping mappingName not found: " + name);