spring-framework / org.springframework.web.reactive.handler / SimpleUrlHandlerMapping

SimpleUrlHandlerMapping

open class SimpleUrlHandlerMapping : AbstractUrlHandlerMapping

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, like 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.

Author
Rossen Stoyanchev

Since
5.0

Constructors

<init>

SimpleUrlHandlerMapping()

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, like 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.

Functions

getUrlMap

open fun getUrlMap(): MutableMap<String, *>

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

open fun initApplicationContext(): Unit

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

setMappings

open fun setMappings(mappings: Properties): Unit

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.

setUrlMap

open fun setUrlMap(urlMap: MutableMap<String, *>): Unit

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.