org.springframework.web.servlet.handler
Class SimpleUrlHandlerMapping

java.lang.Object
  extended by org.springframework.context.support.ApplicationObjectSupport
      extended by org.springframework.web.context.support.WebApplicationObjectSupport
          extended by org.springframework.web.servlet.handler.AbstractHandlerMapping
              extended by org.springframework.web.servlet.handler.AbstractUrlHandlerMapping
                  extended by org.springframework.web.servlet.handler.SimpleUrlHandlerMapping
All Implemented Interfaces:
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 references, e.g. 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, 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 in the "/test" directory, "/test/**" matches all paths below "/test". For details, see the AntPathMatcher javadoc.

Author:
Rod Johnson, Juergen Hoeller
See Also:
DispatcherServlet, AntPathMatcher, Properties

Field Summary
 
Fields inherited from class org.springframework.context.support.ApplicationObjectSupport
logger
 
Constructor Summary
SimpleUrlHandlerMapping()
           
 
Method Summary
 Map getUrlMap()
          Allow Map access to the URL path mappings, with the option to add or override specific entries.
 void initApplicationContext()
          Calls the registerHandlers method in addition to the superclass's initialization.
 void setMappings(Properties mappings)
          Map URL paths to handler bean names.
 void setUrlMap(Map 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.servlet.handler.AbstractUrlHandlerMapping
getHandlerInternal, getHandlerMap, lookupHandler, registerHandler, setAlwaysUseFullPath, setLazyInitHandlers, setPathMatcher, setUrlDecode, setUrlPathHelper
 
Methods inherited from class org.springframework.web.servlet.handler.AbstractHandlerMapping
getDefaultHandler, getHandler, getOrder, setDefaultHandler, setInterceptors, setOrder
 
Methods inherited from class org.springframework.web.context.support.WebApplicationObjectSupport
getServletContext, getTempDir, getWebApplicationContext, isContextRequired
 
Methods inherited from class org.springframework.context.support.ApplicationObjectSupport
getApplicationContext, getMessageSourceAccessor, 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()
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 AntPathMatcher class.

Parameters:
mappings - properties with URLs as keys and bean names as values
See Also:
AntPathMatcher

setUrlMap

public void setUrlMap(Map 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 AntPathMatcher class.

Parameters:
urlMap - map with URLs as keys and beans as values
See Also:
AntPathMatcher

getUrlMap

public Map 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 BeansException
Calls the registerHandlers method in addition to the superclass's initialization.

Overrides:
initApplicationContext in class ApplicationObjectSupport
Throws:
ApplicationContextException - in case of initialization errors
BeansException - if thrown by ApplicationContext methods
See Also:
ApplicationObjectSupport.setApplicationContext(org.springframework.context.ApplicationContext)


Copyright (c) 2002-2007 The Spring Framework Project.