类 AbstractHandlerMapping
- java.lang.Object
- org.springframework.context.support.ApplicationObjectSupport
- org.springframework.web.reactive.handler.AbstractHandlerMapping
- 所有已实现的接口:
Aware
,BeanNameAware
,ApplicationContextAware
,Ordered
,HandlerMapping
public abstract class AbstractHandlerMapping extends ApplicationObjectSupport implements HandlerMapping, Ordered, BeanNameAware
Abstract base class forHandlerMapping
implementations.- 从以下版本开始:
- 5.0
- 作者:
- Rossen Stoyanchev, Juergen Hoeller, Brian Clozel
字段概要
从类继承的字段 org.springframework.context.support.ApplicationObjectSupport
logger
从接口继承的字段 org.springframework.web.reactive.HandlerMapping
BEST_MATCHING_HANDLER_ATTRIBUTE, BEST_MATCHING_PATTERN_ATTRIBUTE, MATRIX_VARIABLES_ATTRIBUTE, PATH_WITHIN_HANDLER_MAPPING_ATTRIBUTE, PRODUCIBLE_MEDIA_TYPES_ATTRIBUTE, URI_TEMPLATE_VARIABLES_ATTRIBUTE
从接口继承的字段 org.springframework.core.Ordered
HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE
构造器概要
构造器 构造器 说明 AbstractHandlerMapping()
方法概要
所有方法 实例方法 抽象方法 具体方法 修饰符和类型 方法 说明 protected String
formatMappingName()
protected CorsConfiguration
getCorsConfiguration(Object handler, ServerWebExchange exchange)
Retrieve the CORS configuration for the given handler.CorsProcessor
getCorsProcessor()
Return the configuredCorsProcessor
.reactor.core.publisher.Mono<Object>
getHandler(ServerWebExchange exchange)
Return a handler for this request.protected abstract reactor.core.publisher.Mono<?>
getHandlerInternal(ServerWebExchange exchange)
Look up a handler for the given request, returning an emptyMono
if no specific one is found.int
getOrder()
Get the order value of this object.PathPatternParser
getPathPatternParser()
Return thePathPatternParser
instance that is used forCORS configuration checks
.protected boolean
hasCorsConfigurationSource(Object handler)
Returntrue
if there is aCorsConfigurationSource
for this handler.void
setBeanName(String name)
Set the name of the bean in the bean factory that created this bean.void
setCorsConfigurations(Map<String,CorsConfiguration> corsConfigurations)
Set the "global" CORS configurations based on URL patterns.void
setCorsConfigurationSource(CorsConfigurationSource corsConfigurationSource)
Set the "global" CORS configuration source.void
setCorsProcessor(CorsProcessor corsProcessor)
Configure a customCorsProcessor
to use to apply the matchedCorsConfiguration
for a request.void
setOrder(int order)
Specify the order value for this HandlerMapping bean.void
setUseCaseSensitiveMatch(boolean caseSensitiveMatch)
Shortcut method for setting the same property on the underlying pattern parser in use.void
setUseTrailingSlashMatch(boolean trailingSlashMatch)
Shortcut method for setting the same property on the underlying pattern parser in use.从类继承的方法 org.springframework.context.support.ApplicationObjectSupport
getApplicationContext, getMessageSourceAccessor, initApplicationContext, initApplicationContext, isContextRequired, obtainApplicationContext, requiredContextClass, setApplicationContext
构造器详细资料
AbstractHandlerMapping
public AbstractHandlerMapping()
方法详细资料
setUseCaseSensitiveMatch
public void setUseCaseSensitiveMatch(boolean caseSensitiveMatch)
Shortcut method for setting the same property on the underlying pattern parser in use. For more details see:getPathPatternParser()
-- the underlying pattern parserPathPatternParser.setCaseSensitive(boolean)
-- the case sensitive slash option, including its default value.
Note: aside from
setUseTrailingSlashMatch
public void setUseTrailingSlashMatch(boolean trailingSlashMatch)
Shortcut method for setting the same property on the underlying pattern parser in use. For more details see:getPathPatternParser()
-- the underlying pattern parserPathPatternParser.setMatchOptionalTrailingSeparator(boolean)
-- the trailing slash option, including its default value.
getPathPatternParser
public PathPatternParser getPathPatternParser()
Return thePathPatternParser
instance that is used forCORS configuration checks
. Sub-classes can also use this pattern parser for their own request mapping purposes.
setCorsConfigurations
public void setCorsConfigurations(Map<String,CorsConfiguration> corsConfigurations)
Set the "global" CORS configurations based on URL patterns. By default the first matching URL pattern is combined with handler-level CORS configuration if any.
setCorsConfigurationSource
public void setCorsConfigurationSource(CorsConfigurationSource corsConfigurationSource)
Set the "global" CORS configuration source. By default the first matching URL pattern is combined with the CORS configuration for the handler, if any.- 从以下版本开始:
- 5.1
- 另请参阅:
setCorsConfigurations(Map)
setCorsProcessor
public void setCorsProcessor(CorsProcessor corsProcessor)
Configure a customCorsProcessor
to use to apply the matchedCorsConfiguration
for a request.By default an instance of
DefaultCorsProcessor
is used.
getCorsProcessor
public CorsProcessor getCorsProcessor()
Return the configuredCorsProcessor
.
setOrder
public void setOrder(int order)
Specify the order value for this HandlerMapping bean.The default value is
Ordered.LOWEST_PRECEDENCE
, meaning non-ordered.- 另请参阅:
Ordered.getOrder()
getOrder
public int getOrder()
从接口复制的说明:Ordered
Get the order value of this object.Higher values are interpreted as lower priority. As a consequence, the object with the lowest value has the highest priority (somewhat analogous to Servlet
load-on-startup
values).Same order values will result in arbitrary sort positions for the affected objects.
- 指定者:
getOrder
在接口中Ordered
- 返回:
- the order value
- 另请参阅:
Ordered.HIGHEST_PRECEDENCE
,Ordered.LOWEST_PRECEDENCE
setBeanName
public void setBeanName(String name)
从接口复制的说明:BeanNameAware
Set the name of the bean in the bean factory that created this bean.Invoked after population of normal bean properties but before an init callback such as
InitializingBean.afterPropertiesSet()
or a custom init-method.- 指定者:
setBeanName
在接口中BeanNameAware
- 参数:
name
- the name of the bean in the factory. Note that this name is the actual bean name used in the factory, which may differ from the originally specified name: in particular for inner bean names, the actual bean name might have been made unique through appending "#..." suffixes. Use theBeanFactoryUtils.originalBeanName(String)
method to extract the original bean name (without suffix), if desired.
formatMappingName
protected String formatMappingName()
getHandler
public reactor.core.publisher.Mono<Object> getHandler(ServerWebExchange exchange)
从接口复制的说明:HandlerMapping
Return a handler for this request.- 指定者:
getHandler
在接口中HandlerMapping
- 参数:
exchange
- current server exchange- 返回:
- a
Mono
that emits one value or none in case the request cannot be resolved to a handler
getHandlerInternal
protected abstract reactor.core.publisher.Mono<?> getHandlerInternal(ServerWebExchange exchange)
Look up a handler for the given request, returning an emptyMono
if no specific one is found. This method is called bygetHandler(org.springframework.web.server.ServerWebExchange)
.On CORS pre-flight requests this method should return a match not for the pre-flight request but for the expected actual request based on the URL path, the HTTP methods from the "Access-Control-Request-Method" header, and the headers from the "Access-Control-Request-Headers" header.
- 参数:
exchange
- current exchange- 返回:
Mono
for the matching handler, if any
hasCorsConfigurationSource
protected boolean hasCorsConfigurationSource(Object handler)
Returntrue
if there is aCorsConfigurationSource
for this handler.- 从以下版本开始:
- 5.2
getCorsConfiguration
@Nullable protected CorsConfiguration getCorsConfiguration(Object handler, ServerWebExchange exchange)
Retrieve the CORS configuration for the given handler.- 参数:
handler
- the handler to check (nevernull
)exchange
- the current exchange- 返回:
- the CORS configuration for the handler, or
null
if none