org.springframework.web.servlet.handler
Class BeanNameUrlHandlerMapping

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.AbstractDetectingUrlHandlerMapping
                      extended by org.springframework.web.servlet.handler.BeanNameUrlHandlerMapping
All Implemented Interfaces:
Aware, ApplicationContextAware, Ordered, ServletContextAware, HandlerMapping

public class BeanNameUrlHandlerMapping
extends AbstractDetectingUrlHandlerMapping

Implementation of the HandlerMapping interface that map from URLs to beans with names that start with a slash ("/"), similar to how Struts maps URLs to action names.

This is the default implementation used by the DispatcherServlet, along with DefaultAnnotationHandlerMapping (on Java 5 and higher). Alternatively, SimpleUrlHandlerMapping allows for customizing a handler mapping declaratively.

The mapping is from URL to bean name. Thus an incoming URL "/foo" would map to a handler named "/foo", or to "/foo /foo2" in case of multiple mappings to a single handler. Note: In XML definitions, you'll need to use an alias name="/foo" in the bean definition, as the XML id may not contain slashes.

Supports direct matches (given "/test" -> registered "/test") and "*" matches (given "/test" -> registered "/t*"). Note that the default is to map within the current servlet mapping if applicable; see the "alwaysUseFullPath" property for details. For details on the pattern options, see the AntPathMatcher javadoc.

Author:
Rod Johnson, Juergen Hoeller
See Also:
SimpleUrlHandlerMapping

Field Summary
 
Fields inherited from class org.springframework.context.support.ApplicationObjectSupport
logger
 
Fields inherited from interface org.springframework.web.servlet.HandlerMapping
BEST_MATCHING_PATTERN_ATTRIBUTE, INTROSPECT_TYPE_LEVEL_MAPPING, PATH_WITHIN_HANDLER_MAPPING_ATTRIBUTE, URI_TEMPLATE_VARIABLES_ATTRIBUTE
 
Fields inherited from interface org.springframework.core.Ordered
HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE
 
Constructor Summary
BeanNameUrlHandlerMapping()
           
 
Method Summary
protected  String[] determineUrlsForHandler(String beanName)
          Checks name and aliases of the given bean for URLs, starting with "/".
 
Methods inherited from class org.springframework.web.servlet.handler.AbstractDetectingUrlHandlerMapping
detectHandlers, initApplicationContext, setDetectHandlersInAncestorContexts
 
Methods inherited from class org.springframework.web.servlet.handler.AbstractUrlHandlerMapping
buildPathExposingHandler, exposePathWithinMapping, exposeUriTemplateVariables, getHandlerInternal, getHandlerMap, getPathMatcher, getRootHandler, initInterceptors, lookupHandler, registerHandler, registerHandler, setAlwaysUseFullPath, setLazyInitHandlers, setMappedInterceptors, setPathMatcher, setRootHandler, setUrlDecode, setUrlPathHelper, supportsTypeLevelMappings, validateHandler
 
Methods inherited from class org.springframework.web.servlet.handler.AbstractHandlerMapping
adaptInterceptor, extendInterceptors, getAdaptedInterceptors, getDefaultHandler, getHandler, getHandlerExecutionChain, getOrder, setDefaultHandler, setInterceptors, setOrder
 
Methods inherited from class org.springframework.web.context.support.WebApplicationObjectSupport
getServletContext, getTempDir, getWebApplicationContext, initApplicationContext, initServletContext, isContextRequired, setServletContext
 
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

BeanNameUrlHandlerMapping

public BeanNameUrlHandlerMapping()
Method Detail

determineUrlsForHandler

protected String[] determineUrlsForHandler(String beanName)
Checks name and aliases of the given bean for URLs, starting with "/".

Specified by:
determineUrlsForHandler in class AbstractDetectingUrlHandlerMapping
Parameters:
beanName - the name of the candidate bean
Returns:
the URLs determined for the bean, or null or an empty array if none