Class SimpleUrlHandlerMapping
- All Implemented Interfaces:
- Aware,- BeanNameAware,- ApplicationContextAware,- Ordered,- ServletContextAware,- MatchableHandlerMapping,- HandlerMapping
- Direct Known Subclasses:
- WebSocketHandlerMapping
HandlerMapping
 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, for example, 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 "*"
 matches (given "/test" -> registered "/t*"). For details on the pattern
 options, see the PathPattern
 javadoc.
- Author:
- Rod Johnson, Juergen Hoeller, Sam Brannen
- See Also:
- 
Field SummaryFields inherited from class org.springframework.web.servlet.handler.AbstractHandlerMappingmappingsLoggerFields inherited from class org.springframework.context.support.ApplicationObjectSupportloggerFields inherited from interface org.springframework.web.servlet.HandlerMappingBEST_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_ATTRIBUTEFields inherited from interface org.springframework.core.OrderedHIGHEST_PRECEDENCE, LOWEST_PRECEDENCE
- 
Constructor SummaryConstructorsConstructorDescriptionCreate aSimpleUrlHandlerMappingwith default settings.SimpleUrlHandlerMapping(Map<String, ?> urlMap) Create aSimpleUrlHandlerMappingusing the supplied URL map.SimpleUrlHandlerMapping(Map<String, ?> urlMap, int order) Create aSimpleUrlHandlerMappingusing the supplied URL map and order.
- 
Method SummaryModifier and TypeMethodDescriptionAllowMapaccess to the URL path mappings, with the option to add or override specific entries.voidCalls theregisterHandlers(java.util.Map<java.lang.String, java.lang.Object>)method in addition to the superclass's initialization.protected voidregisterHandlers(Map<String, Object> urlMap) Register all handlers specified in the URL map for the corresponding paths.voidsetMappings(Properties mappings) Map URL paths to handler bean names.voidSet a Map with URL paths as keys and handler beans (or handler bean names) as values.Methods inherited from class org.springframework.web.servlet.handler.AbstractUrlHandlerMappingbuildPathExposingHandler, exposePathWithinMapping, exposeUriTemplateVariables, getHandlerInternal, getHandlerMap, getPathPatternHandlerMap, getRootHandler, lookupHandler, lookupHandler, match, registerHandler, registerHandler, setLazyInitHandlers, setPatternParser, setRootHandler, supportsTypeLevelMappings, unregisterHandler, validateHandlerMethods inherited from class org.springframework.web.servlet.handler.AbstractHandlerMappingadaptInterceptor, detectMappedInterceptors, extendInterceptors, formatMappingName, getAdaptedInterceptors, getCorsConfiguration, getCorsConfigurationSource, getCorsHandlerExecutionChain, getCorsProcessor, getDefaultHandler, getHandler, getHandlerExecutionChain, getMappedInterceptors, getOrder, getPathMatcher, getPatternParser, getUrlPathHelper, hasCorsConfigurationSource, initInterceptors, initLookupPath, setAlwaysUseFullPath, setBeanName, setCorsConfigurations, setCorsConfigurationSource, setCorsProcessor, setDefaultHandler, setInterceptors, setOrder, setPathMatcher, setRemoveSemicolonContent, setUrlDecode, setUrlPathHelper, usesPathPatternsMethods inherited from class org.springframework.web.context.support.WebApplicationObjectSupportgetServletContext, getTempDir, getWebApplicationContext, initApplicationContext, initServletContext, isContextRequired, setServletContextMethods inherited from class org.springframework.context.support.ApplicationObjectSupportgetApplicationContext, getMessageSourceAccessor, obtainApplicationContext, requiredContextClass, setApplicationContextMethods inherited from class java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.springframework.web.servlet.HandlerMappinggetHandler, usesPathPatternsMethods inherited from interface org.springframework.web.servlet.handler.MatchableHandlerMappinggetPatternParser
- 
Constructor Details- 
SimpleUrlHandlerMappingpublic SimpleUrlHandlerMapping()Create aSimpleUrlHandlerMappingwith default settings.
- 
SimpleUrlHandlerMappingCreate aSimpleUrlHandlerMappingusing the supplied URL map.- Parameters:
- urlMap- map with URL paths as keys and handler beans (or handler bean names) as values
- Since:
- 5.2
- See Also:
 
- 
SimpleUrlHandlerMappingCreate aSimpleUrlHandlerMappingusing the supplied URL map and order.- Parameters:
- urlMap- map with URL paths as keys and handler beans (or handler bean names) as values
- order- the order value for this- SimpleUrlHandlerMapping
- Since:
- 5.2
- See Also:
 
 
- 
- 
Method Details- 
setMappingsMap 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 AntPathMatcherjavadoc.- Parameters:
- mappings- properties with URLs as keys and bean names as values
- See Also:
 
- 
setUrlMapSet 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 AntPathMatcherjavadoc.- Parameters:
- urlMap- map with URLs as keys and beans as values
- See Also:
 
- 
getUrlMapAllowMapaccess 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. 
- 
initApplicationContextCalls theregisterHandlers(java.util.Map<java.lang.String, java.lang.Object>)method in addition to the superclass's initialization.- Overrides:
- initApplicationContextin class- AbstractHandlerMapping
- Throws:
- ApplicationContextException- in case of initialization errors
- BeansException- if thrown by ApplicationContext methods
- See Also:
 
- 
registerHandlersRegister all handlers specified in the URL map for the corresponding paths.- Parameters:
- urlMap- a Map with URL paths as keys and handler beans or bean names as values
- Throws:
- BeansException- if a handler couldn't be registered
- IllegalStateException- if there is a conflicting handler registered
 
 
-