Class ControllerBeanNameHandlerMapping

  extended by
      extended by
          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
                          extended by
All Implemented Interfaces:
ApplicationContextAware, Ordered, ServletContextAware, HandlerMapping

public class ControllerBeanNameHandlerMapping
extends AbstractControllerUrlHandlerMapping

Implementation of HandlerMapping that follows a simple convention for generating URL path mappings from the bean names of registered Controller and ThrowawayController beans as well as @Controller annotated beans.

This is similar to BeanNameUrlHandlerMapping but doesn't expect bean names to follow the URL convention: It turns plain bean names into URLs by prepending a slash and optionally applying a specified prefix and/or suffix. However, it only does so for well-known controller types, as listed above (analogous to ControllerClassNameHandlerMapping).

Juergen Hoeller
See Also:
ControllerClassNameHandlerMapping, BeanNameUrlHandlerMapping

Field Summary
Fields inherited from class
Fields inherited from interface org.springframework.web.servlet.HandlerMapping
Fields inherited from interface org.springframework.core.Ordered
Constructor Summary
Method Summary
protected  String[] buildUrlsForHandler(String beanName, Class beanClass)
          Abstract template method to be implemented by subclasses.
protected  String generatePathMapping(String beanName)
          Prepends a '/' if required and appends the URL suffix to the name.
 void setUrlPrefix(String urlPrefix)
          Set an optional prefix to prepend to generated URL mappings.
 void setUrlSuffix(String urlSuffix)
          Set an optional suffix to append to generated URL mappings.
Methods inherited from class
determineUrlsForHandler, isControllerType, isEligibleForMapping, isMultiActionControllerType, setExcludedClasses, setExcludedPackages, setIncludeAnnotatedControllers
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, getHandlerInternal, getHandlerMap, getPathMatcher, getRootHandler, lookupHandler, registerHandler, registerHandler, setAlwaysUseFullPath, setLazyInitHandlers, setPathMatcher, setRootHandler, setUrlDecode, setUrlPathHelper, validateHandler
Methods inherited from class org.springframework.web.servlet.handler.AbstractHandlerMapping
adaptInterceptor, extendInterceptors, getAdaptedInterceptors, getDefaultHandler, getHandler, getHandlerExecutionChain, getOrder, initInterceptors, setDefaultHandler, setInterceptors, setOrder
Methods inherited from class
getServletContext, getTempDir, getWebApplicationContext, initApplicationContext, initServletContext, isContextRequired, setServletContext
Methods inherited from class
getApplicationContext, getMessageSourceAccessor, requiredContextClass, setApplicationContext
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructor Detail


public ControllerBeanNameHandlerMapping()
Method Detail


public void setUrlPrefix(String urlPrefix)
Set an optional prefix to prepend to generated URL mappings.

By default this is an empty String. If you want a prefix like "/myapp/", you can set it for all beans mapped by this mapping.


public void setUrlSuffix(String urlSuffix)
Set an optional suffix to append to generated URL mappings.

By default this is an empty String. If you want a suffix like ".do", you can set it for all beans mapped by this mapping.


protected String[] buildUrlsForHandler(String beanName,
                                       Class beanClass)
Description copied from class: AbstractControllerUrlHandlerMapping
Abstract template method to be implemented by subclasses.

Specified by:
buildUrlsForHandler in class AbstractControllerUrlHandlerMapping
beanName - the name of the bean
beanClass - the type of the bean
the URLs determined for the bean


protected String generatePathMapping(String beanName)
Prepends a '/' if required and appends the URL suffix to the name.

Copyright © 2002-2008 The Spring Framework.