Top Description Inners Fields Constructors Methods
org.springframework.web.servlet.mvc.method

public abstract Class RequestMappingInfoHandlerMapping

extends AbstractHandlerMethodMapping<RequestMappingInfo>
Class Inheritance
Known Direct Subclasses
org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping
Imports
java.lang.reflect.Method, java.util.ArrayList, .Collections, .Comparator, .LinkedHashMap, .LinkedHashSet, .List, .Map, .Set, jakarta.servlet.ServletException, jakarta.servlet.http.HttpServletRequest, org.springframework.http.HttpHeaders, .HttpMethod, .InvalidMediaTypeException, .MediaType, org.springframework.http.server.PathContainer, org.springframework.lang.Nullable, org.springframework.util.Assert, .CollectionUtils, .MultiValueMap, .StringUtils, org.springframework.web.HttpMediaTypeNotAcceptableException, .HttpMediaTypeNotSupportedException, .HttpRequestMethodNotSupportedException, org.springframework.web.bind.UnsatisfiedServletRequestParameterException, org.springframework.web.bind.annotation.RequestMethod, org.springframework.web.filter.ServerHttpObservationFilter, org.springframework.web.method.HandlerMethod, org.springframework.web.servlet.HandlerMapping, org.springframework.web.servlet.handler.AbstractHandlerMethodMapping, org.springframework.web.servlet.mvc.condition.NameValueExpression, .PathPatternsRequestCondition, .PatternsRequestCondition, .ProducesRequestCondition, .RequestCondition, org.springframework.web.util.ServletRequestPathUtils, .WebUtils, org.springframework.web.util.pattern.PathPattern

Abstract base class for classes for which RequestMappingInfo defines the mapping between a request and a handler method.
Authors
Arjen Poutsma, Rossen Stoyanchev
Since
3.1

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class
RequestMappingInfoHandlerMapping.HttpOptionsHandler

Default handler for HTTP OPTIONS.

private static class
RequestMappingInfoHandlerMapping.PartialMatchHelper

Aggregate all partial matches and expose methods checking across them.

Field Summary

Modifier and TypeField and Description
private static final Method

Constructor Summary

AccessConstructor and Description
protected

Method Summary

Modifier and TypeMethod and Description
private void
private void
private Map<String, MultiValueMap<String, String>>
protected Set<String>
protected HandlerMethod
getHandlerInternal(HttpServletRequest
current HTTP request
request
)

Overrides org.springframework.web.servlet.handler.AbstractHandlerMethodMapping.getHandlerInternal.

Look up a handler method for the given request.

protected Comparator<RequestMappingInfo>
getMappingComparator(final HttpServletRequest
the current request
request
)

Implements abstract org.springframework.web.servlet.handler.AbstractHandlerMethodMapping.getMappingComparator.

Provide a Comparator to sort RequestMappingInfos matched to a request.

protected Set<String>
protected RequestMappingInfo

Returns:

an info in case of a match; or null otherwise.
getMatchingMapping
(RequestMappingInfo
the mapping to get a match for
info
,
HttpServletRequest
the current HTTP servlet request
request
)

Implements abstract org.springframework.web.servlet.handler.AbstractHandlerMethodMapping.getMatchingMapping.

Check if the given RequestMappingInfo matches the current request and return a (potentially new) instance with conditions that match the current request -- for example with a subset of URL patterns.

protected void
handleMatch(RequestMappingInfo
the matching mapping
info
,
String
mapping lookup path within the current servlet mapping
lookupPath
,
HttpServletRequest
the current request
request
)

Overrides org.springframework.web.servlet.handler.AbstractHandlerMethodMapping.handleMatch.

Expose URI template variables, matrix variables, and producible media types in the request.

protected HandlerMethod
handleNoMatch(Set<RequestMappingInfo>
all registered mappings
infos
,
String
mapping lookup path within the current servlet mapping
lookupPath
,
HttpServletRequest
the current request
request
)

Overrides org.springframework.web.servlet.handler.AbstractHandlerMethodMapping.handleNoMatch.

Iterate all RequestMappingInfo's once again, look if any match by URL at least and raise exceptions according to what doesn't match.

Inherited from org.springframework.web.servlet.handler.AbstractHandlerMethodMapping:
afterPropertiesSetcreateHandlerMethoddetectHandlerMethodsgetCandidateBeanNamesgetCorsConfigurationgetHandlerMethodsgetHandlerMethodsForMappingNamegetMappingForMethodgetNamingStrategyhandlerMethodsInitializedhasCorsConfigurationSourceinitCorsConfigurationinitHandlerMethodsisHandlerlookupHandlerMethodprocessCandidateBeanregisterHandlerMethodregisterMappingsetDetectHandlerMethodsInAncestorContextssetHandlerMethodMappingNamingStrategysetPatternParserunregisterMapping

Field Detail

HTTP_OPTIONS_HANDLE_METHODback to summary
private static final Method HTTP_OPTIONS_HANDLE_METHOD

Constructor Detail

RequestMappingInfoHandlerMappingback to summary
protected RequestMappingInfoHandlerMapping()

Method Detail

extractMatchDetailsback to summary
private void extractMatchDetails(PathPatternsRequestCondition condition, String lookupPath, HttpServletRequest request)
extractMatchDetailsback to summary
private void extractMatchDetails(PatternsRequestCondition condition, String lookupPath, HttpServletRequest request)
extractMatrixVariablesback to summary
private Map<String, MultiValueMap<String, String>> extractMatrixVariables(HttpServletRequest request, Map<String, String> uriVariables)
getDirectPathsback to summary
protected Set<String> getDirectPaths(RequestMappingInfo info)

Overrides org.springframework.web.servlet.handler.AbstractHandlerMethodMapping.getDirectPaths.

Doc from org.springframework.web.servlet.handler.AbstractHandlerMethodMapping.getDirectPaths.

Return the request mapping paths that are not patterns.

Annotations
@Override
getHandlerInternalback to summary
protected HandlerMethod getHandlerInternal(HttpServletRequest request) throws Exception

Overrides org.springframework.web.servlet.handler.AbstractHandlerMethodMapping.getHandlerInternal.

Doc from org.springframework.web.servlet.handler.AbstractHandlerMethodMapping.getHandlerInternal.

Look up a handler method for the given request.

Parameters
request:HttpServletRequest

Doc from org.springframework.web.servlet.handler.AbstractHandlerMapping.getHandlerInternal.

current HTTP request

Returns:HandlerMethod

Doc from org.springframework.web.servlet.handler.AbstractHandlerMapping.getHandlerInternal.

the corresponding handler instance, or null if none found

Annotations
@Override
@Nullable
Exceptions
Exception:

Doc from org.springframework.web.servlet.handler.AbstractHandlerMapping.getHandlerInternal.

if there is an internal error

getMappingComparatorback to summary
protected Comparator<RequestMappingInfo> getMappingComparator(final HttpServletRequest request)

Implements abstract org.springframework.web.servlet.handler.AbstractHandlerMethodMapping.getMappingComparator.

Provide a Comparator to sort RequestMappingInfos matched to a request.

Parameters
request:HttpServletRequest

Doc from org.springframework.web.servlet.handler.AbstractHandlerMethodMapping.getMappingComparator.

the current request

Returns:Comparator<RequestMappingInfo>

Doc from org.springframework.web.servlet.handler.AbstractHandlerMethodMapping.getMappingComparator.

the comparator (never null)

Annotations
@Override
getMappingPathPatternsback to summary
protected Set<String> getMappingPathPatterns(RequestMappingInfo info)

Overrides org.springframework.web.servlet.handler.AbstractHandlerMethodMapping.getMappingPathPatterns.

Get the URL path patterns associated with the supplied RequestMappingInfo.

Annotations
@Override
@SuppressWarnings:deprecation
getMatchingMappingback to summary
protected RequestMappingInfo getMatchingMapping(RequestMappingInfo info, HttpServletRequest request)

Implements abstract org.springframework.web.servlet.handler.AbstractHandlerMethodMapping.getMatchingMapping.

Check if the given RequestMappingInfo matches the current request and return a (potentially new) instance with conditions that match the current request -- for example with a subset of URL patterns.

Parameters
info:RequestMappingInfo

Doc from org.springframework.web.servlet.handler.AbstractHandlerMethodMapping.getMatchingMapping.

the mapping to get a match for

request:HttpServletRequest

Doc from org.springframework.web.servlet.handler.AbstractHandlerMethodMapping.getMatchingMapping.

the current HTTP servlet request

Returns:RequestMappingInfo

an info in case of a match; or null otherwise.

Annotations
@Override
handleMatchback to summary
protected void handleMatch(RequestMappingInfo info, String lookupPath, HttpServletRequest request)

Overrides org.springframework.web.servlet.handler.AbstractHandlerMethodMapping.handleMatch.

Expose URI template variables, matrix variables, and producible media types in the request.

Parameters
info:RequestMappingInfo

Doc from org.springframework.web.servlet.handler.AbstractHandlerMethodMapping.handleMatch.

the matching mapping

lookupPath:String

Doc from org.springframework.web.servlet.handler.AbstractHandlerMethodMapping.handleMatch.

mapping lookup path within the current servlet mapping

request:HttpServletRequest

Doc from org.springframework.web.servlet.handler.AbstractHandlerMethodMapping.handleMatch.

the current request

Annotations
@Override
See Also
HandlerMapping#URI_TEMPLATE_VARIABLES_ATTRIBUTE, HandlerMapping#MATRIX_VARIABLES_ATTRIBUTE, HandlerMapping#PRODUCIBLE_MEDIA_TYPES_ATTRIBUTE
handleNoMatchback to summary
protected HandlerMethod handleNoMatch(Set<RequestMappingInfo> infos, String lookupPath, HttpServletRequest request) throws ServletException

Overrides org.springframework.web.servlet.handler.AbstractHandlerMethodMapping.handleNoMatch.

Iterate all RequestMappingInfo's once again, look if any match by URL at least and raise exceptions according to what doesn't match.

Parameters
infos:Set<RequestMappingInfo>

Doc from org.springframework.web.servlet.handler.AbstractHandlerMethodMapping.handleNoMatch.

all registered mappings

lookupPath:String

Doc from org.springframework.web.servlet.handler.AbstractHandlerMethodMapping.handleNoMatch.

mapping lookup path within the current servlet mapping

request:HttpServletRequest

Doc from org.springframework.web.servlet.handler.AbstractHandlerMethodMapping.handleNoMatch.

the current request

Annotations
@Override
Exceptions
ServletException:

Doc from org.springframework.web.servlet.handler.AbstractHandlerMethodMapping.handleNoMatch.

in case of errors

HttpRequestMethodNotSupportedException:
if there are matches by URL but not by HTTP method
HttpMediaTypeNotAcceptableException:
if there are matches by URL but not by consumable/producible media types
org.springframework.web.servlet.mvc.method back to summary

private Class RequestMappingInfoHandlerMapping.HttpOptionsHandler

extends Object
Class Inheritance
  • java.lang.Object
  • org.springframework.web.servlet.mvc.method.RequestMappingInfoHandlerMapping.HttpOptionsHandler

Default handler for HTTP OPTIONS.

Field Summary

Modifier and TypeField and Description
private final HttpHeaders

Constructor Summary

AccessConstructor and Description
public
HttpOptionsHandler(Set<String> declaredMethods, Set<MediaType> acceptPatch)

Method Summary

Modifier and TypeMethod and Description
public HttpHeaders
private static Set<HttpMethod>
initAllowedHttpMethods(Set<String> declaredMethods)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

headersback to summary
private final HttpHeaders headers

Constructor Detail

HttpOptionsHandlerback to summary
public HttpOptionsHandler(Set<String> declaredMethods, Set<MediaType> acceptPatch)

Method Detail

handleback to summary
public HttpHeaders handle()
Annotations
@SuppressWarnings:unused
initAllowedHttpMethodsback to summary
private static Set<HttpMethod> initAllowedHttpMethods(Set<String> declaredMethods)
org.springframework.web.servlet.mvc.method back to summary

private final Class RequestMappingInfoHandlerMapping.PartialMatchHelper

extends Object
Class Inheritance
  • java.lang.Object
  • org.springframework.web.servlet.mvc.method.RequestMappingInfoHandlerMapping.PartialMatchHelper

Aggregate all partial matches and expose methods checking across them.

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class
RequestMappingInfoHandlerMapping.PartialMatchHelper.PartialMatch

Container for a RequestMappingInfo that matches the URL path at least.

Field Summary

Modifier and TypeField and Description
private final List<RequestMappingInfoHandlerMapping.PartialMatchHelper.PartialMatch>

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
public Set<String>
getAllowedMethods()

Return declared HTTP methods.

public Set<MediaType>
getConsumableMediaTypes()

Return declared "consumable" types but only among those that also match the "methods" condition.

public Set<MediaType>
getConsumablePatchMediaTypes()

Return declared "consumable" types but only among those that have PATCH specified, or that have no methods at all.

public List<String[]>
getParamConditions()

Return declared "params" conditions but only among those that also match the "methods", "consumes", and "params" conditions.

public Set<MediaType>
getProducibleMediaTypes()

Return declared "producible" types but only among those that also match the "methods" and "consumes" conditions.

public boolean
hasConsumesMismatch()

Any partial matches for "methods" and "consumes"?

public boolean
hasMethodsMismatch()

Any partial matches for "methods"?

public boolean
hasParamsMismatch()

Any partial matches for "methods", "consumes", "produces", and "params"?

public boolean
hasProducesMismatch()

Any partial matches for "methods", "consumes", and "produces"?

public boolean
isEmpty()

Whether there are any partial matches.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

partialMatchesback to summary
private final List<RequestMappingInfoHandlerMapping.PartialMatchHelper.PartialMatch> partialMatches

Constructor Detail

PartialMatchHelperback to summary
pack-priv PartialMatchHelper(Set<RequestMappingInfo> infos, HttpServletRequest request)

Method Detail

getAllowedMethodsback to summary
public Set<String> getAllowedMethods()

Return declared HTTP methods.

getConsumableMediaTypesback to summary
public Set<MediaType> getConsumableMediaTypes()

Return declared "consumable" types but only among those that also match the "methods" condition.

getConsumablePatchMediaTypesback to summary
public Set<MediaType> getConsumablePatchMediaTypes()

Return declared "consumable" types but only among those that have PATCH specified, or that have no methods at all.

getParamConditionsback to summary
public List<String[]> getParamConditions()

Return declared "params" conditions but only among those that also match the "methods", "consumes", and "params" conditions.

getProducibleMediaTypesback to summary
public Set<MediaType> getProducibleMediaTypes()

Return declared "producible" types but only among those that also match the "methods" and "consumes" conditions.

hasConsumesMismatchback to summary
public boolean hasConsumesMismatch()

Any partial matches for "methods" and "consumes"?

hasMethodsMismatchback to summary
public boolean hasMethodsMismatch()

Any partial matches for "methods"?

hasParamsMismatchback to summary
public boolean hasParamsMismatch()

Any partial matches for "methods", "consumes", "produces", and "params"?

hasProducesMismatchback to summary
public boolean hasProducesMismatch()

Any partial matches for "methods", "consumes", and "produces"?

isEmptyback to summary
public boolean isEmpty()

Whether there are any partial matches.

org.springframework.web.servlet.mvc.method back to summary

private Class RequestMappingInfoHandlerMapping.PartialMatchHelper.PartialMatch

extends Object
Class Inheritance
  • java.lang.Object
  • org.springframework.web.servlet.mvc.method.RequestMappingInfoHandlerMapping.PartialMatchHelper.PartialMatch

Container for a RequestMappingInfo that matches the URL path at least.

Field Summary

Modifier and TypeField and Description
private final boolean
private final RequestMappingInfo
private final boolean
private final boolean
private final boolean

Constructor Summary

AccessConstructor and Description
public
PartialMatch(RequestMappingInfo
the RequestMappingInfo that matches the URL path.
info
,
HttpServletRequest
the current request
request
)

Create a new PartialMatch instance.

Method Summary

Modifier and TypeMethod and Description
public RequestMappingInfo
public boolean
public boolean
public boolean
public boolean
public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

consumesMatchback to summary
private final boolean consumesMatch
infoback to summary
private final RequestMappingInfo info
methodsMatchback to summary
private final boolean methodsMatch
paramsMatchback to summary
private final boolean paramsMatch
producesMatchback to summary
private final boolean producesMatch

Constructor Detail

PartialMatchback to summary
public PartialMatch(RequestMappingInfo info, HttpServletRequest request)

Create a new PartialMatch instance.

Parameters
info:RequestMappingInfo

the RequestMappingInfo that matches the URL path.

request:HttpServletRequest

the current request

Method Detail

getInfoback to summary
public RequestMappingInfo getInfo()
hasConsumesMatchback to summary
public boolean hasConsumesMatch()
hasMethodsMatchback to summary
public boolean hasMethodsMatch()
hasParamsMatchback to summary
public boolean hasParamsMatch()
hasProducesMatchback to summary
public boolean hasProducesMatch()
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object. Satisfying this method's contract implies a non-null result must be returned.

Returns:String

a string representation of the object

Annotations
@Override