Top Description Fields Constructors Methods
org.springframework.web.reactive.handler

public Class SimpleUrlHandlerMapping

extends AbstractUrlHandlerMapping
Class Inheritance
Imports
java.util.LinkedHashMap, .Map, .Properties, org.springframework.beans.BeansException, org.springframework.util.CollectionUtils

Implementation of the org.springframework.web.reactive.HandlerMapping interface to map 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 instances. 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, e.g. a registered "/test" matches "/test", and various Ant-style pattern matches, e.g. a registered "/t*" pattern matches both "/test" and "/team", "/test/*" matches all paths under "/test", "/test/**" matches all paths below "/test". For details, see the org.springframework.web.util.pattern.PathPattern javadoc.

Authors
Rossen Stoyanchev, Sam Brannen
Since
5.0

Field Summary

Modifier and TypeField and Description
private final Map<String, Object>

Constructor Summary

AccessConstructor and Description
public
SimpleUrlHandlerMapping()

Create a SimpleUrlHandlerMapping with default settings.

public
SimpleUrlHandlerMapping(Map<String, ?>
map with URL paths as keys and handler beans (or handler bean names) as values
urlMap
)

Create a SimpleUrlHandlerMapping using the supplied URL map.

public
SimpleUrlHandlerMapping(Map<String, ?>
map with URL paths as keys and handler beans (or handler bean names) as values
urlMap
,
int
the order value for this SimpleUrlHandlerMapping
order
)

Create a SimpleUrlHandlerMapping using the supplied URL map and order.

Method Summary

Modifier and TypeMethod and Description
public Map<String, ?>
getUrlMap()

Allow Map access to the URL path mappings, with the option to add or override specific entries.

public void
private void
protected void
registerHandlers(Map<String, Object>
a Map with URL paths as keys and handler beans or bean names as values
urlMap
)

Register all handlers specified in the URL map for the corresponding paths.

public void
setMappings(Properties
properties with URLs as keys and bean names as values
mappings
)

Map URL paths to handler bean names.

public void
setUrlMap(Map<String, ?>
map with URLs as keys and beans as values
urlMap
)

Set a Map with URL paths as keys and handler beans (or handler bean names) as values.

Inherited from org.springframework.web.reactive.handler.AbstractUrlHandlerMapping:
getHandlerInternalgetHandlerMaplookupHandlerregisterHandlerregisterHandlersetHandlerPredicatesetLazyInitHandlersvalidateHandler

Field Detail

urlMapback to summary
private final Map<String, Object> urlMap

Constructor Detail

SimpleUrlHandlerMappingback to summary
public SimpleUrlHandlerMapping()

Create a SimpleUrlHandlerMapping with default settings.

SimpleUrlHandlerMappingback to summary
public SimpleUrlHandlerMapping(Map<String, ?> urlMap)

Create a SimpleUrlHandlerMapping using the supplied URL map.

Parameters
urlMap:Map<String, ?>

map with URL paths as keys and handler beans (or handler bean names) as values

Since
5.2
See Also
setUrlMap(Map)
SimpleUrlHandlerMappingback to summary
public SimpleUrlHandlerMapping(Map<String, ?> urlMap, int order)

Create a SimpleUrlHandlerMapping using the supplied URL map and order.

Parameters
urlMap:Map<String, ?>

map with URL paths as keys and handler beans (or handler bean names) as values

order:int

the order value for this SimpleUrlHandlerMapping

Since
5.2
See Also
setUrlMap(Map), setOrder(int)

Method Detail

getUrlMapback to summary
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.

initApplicationContextback to summary
public void initApplicationContext() throws BeansException

Overrides org.springframework.context.support.ApplicationObjectSupport.initApplicationContext.

Calls the registerHandlers method in addition to the superclass's initialization.

Annotations
@Override
Exceptions
BeansException:

Doc from org.springframework.context.support.ApplicationObjectSupport.initApplicationContext.

if thrown by ApplicationContext methods

logMappingsback to summary
private void logMappings()
registerHandlersback to summary
protected void registerHandlers(Map<String, Object> urlMap) throws BeansException

Register all handlers specified in the URL map for the corresponding paths.

Parameters
urlMap:Map<String, Object>

a Map with URL paths as keys and handler beans or bean names as values

Exceptions
BeansException:
if a handler couldn't be registered
IllegalStateException:
if there is a conflicting handler registered
setMappingsback to summary
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 org.springframework.web.util.pattern.PathPattern javadoc.

Parameters
mappings:Properties

properties with URLs as keys and bean names as values

See Also
setUrlMap
setUrlMapback to summary
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 org.springframework.web.util.pattern.PathPattern javadoc.

Parameters
urlMap:Map<String, ?>

map with URLs as keys and beans as values

See Also
setMappings