Class SimpleUrlHandlerMapping

All Implemented Interfaces:
Aware, BeanNameAware, ApplicationContextAware, 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
  • Constructor Details

    • 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:
    • 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:
  • Method Details