org.springframework.web.reactive.handler

## Class SimpleUrlHandlerMapping

- java.lang.Object
- - org.springframework.context.support.ApplicationObjectSupport
  - - org.springframework.web.reactive.handler.AbstractHandlerMapping
    - - org.springframework.web.reactive.handler.AbstractUrlHandlerMapping
      - - org.springframework.web.reactive.handler.SimpleUrlHandlerMapping

All Implemented Interfaces:
  org.springframework.beans.factory.Aware, org.springframework.beans.factory.BeanNameAware, org.springframework.context.ApplicationContextAware, org.springframework.core.Ordered, HandlerMapping

    public class SimpleUrlHandlerMapping
    extends AbstractUrlHandlerMapping

Implementation of the `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 `PathPattern` javadoc.

Since:
  5.0
Author:
  Rossen Stoyanchev, Sam Brannen

### Field Summary

### Fields inherited from class org.springframework.context.support.ApplicationObjectSupport

`logger`

### Fields inherited from interface 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`

### Fields inherited from interface org.springframework.core.Ordered

`HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE`

### Constructor Summary

Constructors
Constructor and Description
`SimpleUrlHandlerMapping()` Create a `SimpleUrlHandlerMapping` with default settings.
`SimpleUrlHandlerMapping(Map<String,?> urlMap)` Create a `SimpleUrlHandlerMapping` using the supplied URL map.
`SimpleUrlHandlerMapping(Map<String,?> urlMap, int order)` Create a `SimpleUrlHandlerMapping` using the supplied URL map and order.

### Method Summary

All Methods Instance Methods Concrete Methods
`Map<String,?>` `getUrlMap()` Allow Map access to the URL path mappings, with the option to add or override specific entries.
`void` `initApplicationContext()` Calls the `registerHandlers(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.

### Methods inherited from class org.springframework.web.reactive.handler.AbstractUrlHandlerMapping

`getHandlerInternal, getHandlerMap, lookupHandler, registerHandler, registerHandler, setLazyInitHandlers, validateHandler`

### Methods inherited from class org.springframework.web.reactive.handler.AbstractHandlerMapping

`formatMappingName, getCorsConfiguration, getCorsProcessor, getHandler, getOrder, getPathPatternParser, hasCorsConfigurationSource, setBeanName, setCorsConfigurations, setCorsConfigurationSource, setCorsProcessor, setOrder, setUseCaseSensitiveMatch, setUseTrailingSlashMatch`

### Methods inherited from class org.springframework.context.support.ApplicationObjectSupport

`getApplicationContext, getMessageSourceAccessor, initApplicationContext, isContextRequired, obtainApplicationContext, requiredContextClass, setApplicationContext`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Constructor Detail

#### SimpleUrlHandlerMapping

    public SimpleUrlHandlerMapping()

Create a `SimpleUrlHandlerMapping` with default settings.

#### SimpleUrlHandlerMapping

    public SimpleUrlHandlerMapping(Map<String,?> urlMap)

Create a `SimpleUrlHandlerMapping` using 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:
  `setUrlMap(Map)`

#### SimpleUrlHandlerMapping

    public SimpleUrlHandlerMapping(Map<String,?> urlMap,
                                   int order)

Create a `SimpleUrlHandlerMapping` using 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:
  `setUrlMap(Map)`, `AbstractHandlerMapping.setOrder(int)`

### Method Detail

#### 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 `PathPattern` javadoc.

Parameters:
  `mappings` - properties with URLs as keys and bean names as values
See Also:
  `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 `PathPattern` javadoc.

Parameters:
  `urlMap` - map with URLs as keys and beans as values
See Also:
  `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 org.springframework.beans.BeansException

Calls the `registerHandlers(java.util.Map<java.lang.String, java.lang.Object>)` method in addition to the superclass's initialization.

Overrides:
  `initApplicationContext` in class `org.springframework.context.support.ApplicationObjectSupport`
Throws:
  `org.springframework.beans.BeansException`

#### registerHandlers

    protected void registerHandlers(Map<String,Object> urlMap)
                             throws org.springframework.beans.BeansException

Register 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:
  `org.springframework.beans.BeansException` - if a handler couldn't be registered
  `IllegalStateException` - if there is a conflicting handler registered