类 RequestMappingHandlerMapping
- java.lang.Object
- org.springframework.context.support.ApplicationObjectSupport
- org.springframework.web.context.support.WebApplicationObjectSupport
- org.springframework.web.servlet.handler.AbstractHandlerMapping
- org.springframework.web.servlet.handler.AbstractHandlerMethodMapping<RequestMappingInfo>
- org.springframework.web.servlet.mvc.method.RequestMappingInfoHandlerMapping
- org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping
- 所有已实现的接口:
Aware
,InitializingBean
,ApplicationContextAware
,EmbeddedValueResolverAware
,Ordered
,ServletContextAware
,MatchableHandlerMapping
,HandlerMapping
public class RequestMappingHandlerMapping extends RequestMappingInfoHandlerMapping implements MatchableHandlerMapping, EmbeddedValueResolverAware
CreatesRequestMappingInfo
instances from type and method-level@RequestMapping
annotations in@Controller
classes.- 从以下版本开始:
- 3.1
- 作者:
- Arjen Poutsma, Rossen Stoyanchev, Sam Brannen
字段概要
从类继承的字段 org.springframework.context.support.ApplicationObjectSupport
logger
从接口继承的字段 org.springframework.web.servlet.HandlerMapping
BEST_MATCHING_HANDLER_ATTRIBUTE, BEST_MATCHING_PATTERN_ATTRIBUTE, INTROSPECT_TYPE_LEVEL_MAPPING, MATRIX_VARIABLES_ATTRIBUTE, PATH_WITHIN_HANDLER_MAPPING_ATTRIBUTE, PRODUCIBLE_MEDIA_TYPES_ATTRIBUTE, URI_TEMPLATE_VARIABLES_ATTRIBUTE
从接口继承的字段 org.springframework.core.Ordered
HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE
构造器概要
构造器 构造器 说明 RequestMappingHandlerMapping()
方法概要
所有方法 实例方法 具体方法 修饰符和类型 方法 说明 void
afterPropertiesSet()
Detects handler methods at initialization.protected RequestMappingInfo
createRequestMappingInfo(RequestMapping requestMapping, RequestCondition<?> customCondition)
Create aRequestMappingInfo
from the supplied@RequestMapping
annotation, which is either a directly declared annotation, a meta-annotation, or the synthesized result of merging annotation attributes within an annotation hierarchy.ContentNegotiationManager
getContentNegotiationManager()
Return the configuredContentNegotiationManager
.protected RequestCondition<?>
getCustomMethodCondition(Method method)
Provide a custom method-level request condition.protected RequestCondition<?>
getCustomTypeCondition(Class<?> handlerType)
Provide a custom type-level request condition.List<String>
getFileExtensions()
Return the file extensions to use for suffix pattern matching.protected RequestMappingInfo
getMappingForMethod(Method method, Class<?> handlerType)
Uses method and type-level @RequestMapping
annotations to create the RequestMappingInfo.protected CorsConfiguration
initCorsConfiguration(Object handler, Method method, RequestMappingInfo mappingInfo)
Extract and return the CORS configuration for the mapping.protected boolean
isHandler(Class<?> beanType)
Whether the given type is a handler with handler methods.RequestMatchResult
match(HttpServletRequest request, String pattern)
Determine whether the given request matches the request criteria.protected String[]
resolveEmbeddedValuesInPatterns(String[] patterns)
Resolve placeholder values in the given array of patterns.void
setContentNegotiationManager(ContentNegotiationManager contentNegotiationManager)
Set theContentNegotiationManager
to use to determine requested media types.void
setEmbeddedValueResolver(StringValueResolver resolver)
Set the StringValueResolver to use for resolving embedded definition values.void
setUseRegisteredSuffixPatternMatch(boolean useRegisteredSuffixPatternMatch)
Whether suffix pattern matching should work only against path extensions explicitly registered with theContentNegotiationManager
.void
setUseSuffixPatternMatch(boolean useSuffixPatternMatch)
Whether to use suffix pattern match (".*") when matching patterns to requests.void
setUseTrailingSlashMatch(boolean useTrailingSlashMatch)
Whether to match to URLs irrespective of the presence of a trailing slash.boolean
useRegisteredSuffixPatternMatch()
Whether to use registered suffixes for pattern matching.boolean
useSuffixPatternMatch()
Whether to use suffix pattern matching.boolean
useTrailingSlashMatch()
Whether to match to URLs irrespective of the presence of a trailing slash.从类继承的方法 org.springframework.web.servlet.mvc.method.RequestMappingInfoHandlerMapping
getMappingComparator, getMappingPathPatterns, getMatchingMapping, handleMatch, handleNoMatch
从类继承的方法 org.springframework.web.servlet.handler.AbstractHandlerMethodMapping
createHandlerMethod, detectHandlerMethods, getCorsConfiguration, getHandlerInternal, getHandlerMethods, getHandlerMethodsForMappingName, getNamingStrategy, handlerMethodsInitialized, initHandlerMethods, lookupHandlerMethod, registerHandlerMethod, registerMapping, setDetectHandlerMethodsInAncestorContexts, setHandlerMethodMappingNamingStrategy, unregisterMapping
从类继承的方法 org.springframework.web.servlet.handler.AbstractHandlerMapping
adaptInterceptor, detectMappedInterceptors, extendInterceptors, getAdaptedInterceptors, getCorsConfigurations, getCorsHandlerExecutionChain, getCorsProcessor, getDefaultHandler, getHandler, getHandlerExecutionChain, getMappedInterceptors, getOrder, getPathMatcher, getUrlPathHelper, initApplicationContext, initInterceptors, setAlwaysUseFullPath, setCorsConfigurations, setCorsProcessor, setDefaultHandler, setInterceptors, setOrder, setPathMatcher, setRemoveSemicolonContent, setUrlDecode, setUrlPathHelper
从类继承的方法 org.springframework.web.context.support.WebApplicationObjectSupport
getServletContext, getTempDir, getWebApplicationContext, initApplicationContext, initServletContext, isContextRequired, setServletContext
从类继承的方法 org.springframework.context.support.ApplicationObjectSupport
getApplicationContext, getMessageSourceAccessor, requiredContextClass, setApplicationContext
从类继承的方法 java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
从接口继承的方法 org.springframework.web.servlet.HandlerMapping
getHandler
构造器详细资料
RequestMappingHandlerMapping
public RequestMappingHandlerMapping()
方法详细资料
setUseSuffixPatternMatch
public void setUseSuffixPatternMatch(boolean useSuffixPatternMatch)
Whether to use suffix pattern match (".*") when matching patterns to requests. If enabled a method mapped to "/users" also matches to "/users.*".The default value is
true
.Also see
setUseRegisteredSuffixPatternMatch(boolean)
for more fine-grained control over specific suffixes to allow.
setUseRegisteredSuffixPatternMatch
public void setUseRegisteredSuffixPatternMatch(boolean useRegisteredSuffixPatternMatch)
Whether suffix pattern matching should work only against path extensions explicitly registered with theContentNegotiationManager
. This is generally recommended to reduce ambiguity and to avoid issues such as when a "." appears in the path for other reasons.By default this is set to "false".
setUseTrailingSlashMatch
public void setUseTrailingSlashMatch(boolean useTrailingSlashMatch)
Whether to match to URLs irrespective of the presence of a trailing slash. If enabled a method mapped to "/users" also matches to "/users/".The default value is
true
.
setContentNegotiationManager
public void setContentNegotiationManager(ContentNegotiationManager contentNegotiationManager)
Set theContentNegotiationManager
to use to determine requested media types. If not set, the default constructor is used.
getContentNegotiationManager
public ContentNegotiationManager getContentNegotiationManager()
Return the configuredContentNegotiationManager
.
setEmbeddedValueResolver
public void setEmbeddedValueResolver(StringValueResolver resolver)
从接口复制的说明:EmbeddedValueResolverAware
Set the StringValueResolver to use for resolving embedded definition values.
afterPropertiesSet
public void afterPropertiesSet()
从类复制的说明:AbstractHandlerMethodMapping
Detects handler methods at initialization.
useSuffixPatternMatch
public boolean useSuffixPatternMatch()
Whether to use suffix pattern matching.
useRegisteredSuffixPatternMatch
public boolean useRegisteredSuffixPatternMatch()
Whether to use registered suffixes for pattern matching.
useTrailingSlashMatch
public boolean useTrailingSlashMatch()
Whether to match to URLs irrespective of the presence of a trailing slash.
getFileExtensions
public List<String> getFileExtensions()
Return the file extensions to use for suffix pattern matching.
isHandler
protected boolean isHandler(Class<?> beanType)
Whether the given type is a handler with handler methods.Expects a handler to have either a type-level @
Controller
annotation or a type-level @RequestMapping
annotation.- 指定者:
isHandler
在类中AbstractHandlerMethodMapping<RequestMappingInfo>
- 参数:
beanType
- the type of the bean being checked- 返回:
- "true" if this a handler type, "false" otherwise.
getMappingForMethod
protected RequestMappingInfo getMappingForMethod(Method method, Class<?> handlerType)
Uses method and type-level @RequestMapping
annotations to create the RequestMappingInfo.- 指定者:
getMappingForMethod
在类中AbstractHandlerMethodMapping<RequestMappingInfo>
- 参数:
method
- the method to provide a mapping forhandlerType
- the handler type, possibly a sub-type of the method's declaring class- 返回:
- the created RequestMappingInfo, or
null
if the method does not have a@RequestMapping
annotation. - 另请参阅:
getCustomMethodCondition(Method)
,getCustomTypeCondition(Class)
getCustomTypeCondition
protected RequestCondition<?> getCustomTypeCondition(Class<?> handlerType)
Provide a custom type-level request condition. The customRequestCondition
can be of any type so long as the same condition type is returned from all calls to this method in order to ensure custom request conditions can be combined and compared.Consider extending
AbstractRequestCondition
for custom condition types and usingCompositeRequestCondition
to provide multiple custom conditions.- 参数:
handlerType
- the handler type for which to create the condition- 返回:
- the condition, or
null
getCustomMethodCondition
protected RequestCondition<?> getCustomMethodCondition(Method method)
Provide a custom method-level request condition. The customRequestCondition
can be of any type so long as the same condition type is returned from all calls to this method in order to ensure custom request conditions can be combined and compared.Consider extending
AbstractRequestCondition
for custom condition types and usingCompositeRequestCondition
to provide multiple custom conditions.- 参数:
method
- the handler method for which to create the condition- 返回:
- the condition, or
null
createRequestMappingInfo
protected RequestMappingInfo createRequestMappingInfo(RequestMapping requestMapping, RequestCondition<?> customCondition)
Create aRequestMappingInfo
from the supplied@RequestMapping
annotation, which is either a directly declared annotation, a meta-annotation, or the synthesized result of merging annotation attributes within an annotation hierarchy.
resolveEmbeddedValuesInPatterns
protected String[] resolveEmbeddedValuesInPatterns(String[] patterns)
Resolve placeholder values in the given array of patterns.- 返回:
- a new array with updated patterns
match
public RequestMatchResult match(HttpServletRequest request, String pattern)
从接口复制的说明:MatchableHandlerMapping
Determine whether the given request matches the request criteria.- 指定者:
match
在接口中MatchableHandlerMapping
- 参数:
request
- the current requestpattern
- the pattern to match- 返回:
- the result from request matching, or
null
if none
initCorsConfiguration
protected CorsConfiguration initCorsConfiguration(Object handler, Method method, RequestMappingInfo mappingInfo)
从类复制的说明:AbstractHandlerMethodMapping
Extract and return the CORS configuration for the mapping.