类 SimpleUrlHandlerMapping
- 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.AbstractUrlHandlerMapping
- org.springframework.web.servlet.handler.SimpleUrlHandlerMapping
- 所有已实现的接口:
Aware
,BeanNameAware
,ApplicationContextAware
,Ordered
,ServletContextAware
,MatchableHandlerMapping
,HandlerMapping
- 直接已知子类:
WebSocketHandlerMapping
public class SimpleUrlHandlerMapping extends AbstractUrlHandlerMapping
Implementation of theHandlerMapping
interface that maps from URLs to request handler beans. Supports both mapping to bean instances and mapping to bean names; the latter is required for non-singleton handlers.The "urlMap" property is suitable for populating the handler map with bean references, e.g. via the map element in XML bean definitions.
Mappings to bean names can be set via the "mappings" property, in a form accepted by the
java.util.Properties
class, as follows:/welcome.html=ticketController /show.html=ticketController
The syntax is
PATH=HANDLER_BEAN_NAME
. If the path doesn't begin with a slash, one is prepended.Supports direct matches (given "/test" -> registered "/test") and "*" pattern matches (given "/test" -> registered "/t*"). Note that the default is to map within the current servlet mapping if applicable; see the
"alwaysUseFullPath"
property. For details on the pattern options, see theAntPathMatcher
javadoc.- 作者:
- Rod Johnson, Juergen Hoeller, Sam Brannen
- 另请参阅:
setMappings(java.util.Properties)
,setUrlMap(java.util.Map<java.lang.String, ?>)
,BeanNameUrlHandlerMapping
字段概要
从类继承的字段 org.springframework.context.support.ApplicationObjectSupport
logger
从接口继承的字段 org.springframework.web.servlet.HandlerMapping
BEST_MATCHING_HANDLER_ATTRIBUTE, BEST_MATCHING_PATTERN_ATTRIBUTE, INTROSPECT_TYPE_LEVEL_MAPPING, LOOKUP_PATH, MATRIX_VARIABLES_ATTRIBUTE, PATH_WITHIN_HANDLER_MAPPING_ATTRIBUTE, PRODUCIBLE_MEDIA_TYPES_ATTRIBUTE, URI_TEMPLATE_VARIABLES_ATTRIBUTE
从接口继承的字段 org.springframework.core.Ordered
HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE
构造器概要
构造器 构造器 说明 SimpleUrlHandlerMapping()
Create aSimpleUrlHandlerMapping
with default settings.SimpleUrlHandlerMapping(Map<String,?> urlMap)
Create aSimpleUrlHandlerMapping
using the supplied URL map.SimpleUrlHandlerMapping(Map<String,?> urlMap, int order)
Create aSimpleUrlHandlerMapping
using the supplied URL map and order.
方法概要
所有方法 实例方法 具体方法 修饰符和类型 方法 说明 Map<String,?>
getUrlMap()
Allow Map access to the URL path mappings, with the option to add or override specific entries.void
initApplicationContext()
Calls theregisterHandlers(java.util.Map<java.lang.String, java.lang.Object>)
method in addition to the superclass's initialization.protected void
registerHandlers(Map<String,Object> urlMap)
Register all handlers specified in the URL map for the corresponding paths.void
setMappings(Properties mappings)
Map URL paths to handler bean names.void
setUrlMap(Map<String,?> urlMap)
Set a Map with URL paths as keys and handler beans (or handler bean names) as values.从类继承的方法 org.springframework.web.servlet.handler.AbstractUrlHandlerMapping
buildPathExposingHandler, exposePathWithinMapping, exposeUriTemplateVariables, getHandlerInternal, getHandlerMap, getRootHandler, lookupHandler, match, registerHandler, registerHandler, setLazyInitHandlers, setRootHandler, setUseTrailingSlashMatch, supportsTypeLevelMappings, useTrailingSlashMatch, validateHandler
从类继承的方法 org.springframework.web.servlet.handler.AbstractHandlerMapping
adaptInterceptor, detectMappedInterceptors, extendInterceptors, formatMappingName, getAdaptedInterceptors, getCorsConfiguration, getCorsHandlerExecutionChain, getCorsProcessor, getDefaultHandler, getHandler, getHandlerExecutionChain, getMappedInterceptors, getOrder, getPathMatcher, getUrlPathHelper, hasCorsConfigurationSource, initInterceptors, setAlwaysUseFullPath, setBeanName, setCorsConfigurations, setCorsConfigurationSource, 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, obtainApplicationContext, requiredContextClass, setApplicationContext
从类继承的方法 java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
从接口继承的方法 org.springframework.web.servlet.HandlerMapping
getHandler
构造器详细资料
SimpleUrlHandlerMapping
public SimpleUrlHandlerMapping()
Create aSimpleUrlHandlerMapping
with default settings.
SimpleUrlHandlerMapping
public SimpleUrlHandlerMapping(Map<String,?> urlMap)
Create aSimpleUrlHandlerMapping
using the supplied URL map.- 参数:
urlMap
- map with URL paths as keys and handler beans (or handler bean names) as values- 从以下版本开始:
- 5.2
- 另请参阅:
setUrlMap(Map)
SimpleUrlHandlerMapping
public SimpleUrlHandlerMapping(Map<String,?> urlMap, int order)
Create aSimpleUrlHandlerMapping
using the supplied URL map and order.- 参数:
urlMap
- map with URL paths as keys and handler beans (or handler bean names) as valuesorder
- the order value for thisSimpleUrlHandlerMapping
- 从以下版本开始:
- 5.2
- 另请参阅:
setUrlMap(Map)
,AbstractHandlerMapping.setOrder(int)
方法详细资料
setMappings
public void setMappings(Properties mappings)
Map URL paths to handler bean names. This is the typical way of configuring this HandlerMapping.Supports direct URL matches and Ant-style pattern matches. For syntax details, see the
AntPathMatcher
javadoc.- 参数:
mappings
- properties with URLs as keys and bean names as values- 另请参阅:
setUrlMap(java.util.Map<java.lang.String, ?>)
setUrlMap
public void setUrlMap(Map<String,?> urlMap)
Set a Map with URL paths as keys and handler beans (or handler bean names) as values. Convenient for population with bean references.Supports direct URL matches and Ant-style pattern matches. For syntax details, see the
AntPathMatcher
javadoc.- 参数:
urlMap
- map with URLs as keys and beans as values- 另请参阅:
setMappings(java.util.Properties)
getUrlMap
public Map<String,?> getUrlMap()
Allow Map access to the URL path mappings, with the option to add or override specific entries.Useful for specifying entries directly, for example via "urlMap[myKey]". This is particularly useful for adding or overriding entries in child bean definitions.
initApplicationContext
public void initApplicationContext() throws BeansException
Calls theregisterHandlers(java.util.Map<java.lang.String, java.lang.Object>)
method in addition to the superclass's initialization.- 覆盖:
initApplicationContext
在类中AbstractHandlerMapping
- 抛出:
ApplicationContextException
- in case of initialization errorsBeansException
- if thrown by ApplicationContext methods- 另请参阅:
AbstractHandlerMapping.extendInterceptors(java.util.List)
,AbstractHandlerMapping.initInterceptors()
registerHandlers
protected void registerHandlers(Map<String,Object> urlMap) throws BeansException
Register all handlers specified in the URL map for the corresponding paths.- 参数:
urlMap
- a Map with URL paths as keys and handler beans or bean names as values- 抛出:
BeansException
- if a handler couldn't be registeredIllegalStateException
- if there is a conflicting handler registered