org.springframework.web.servlet.mvc.support
Class ControllerBeanNameHandlerMapping
java.lang.Object
org.springframework.context.support.ApplicationObjectSupport
org.springframework.web.context.support.WebApplicationObjectSupport
org.springframework.web.servlet.handler.AbstractHandlerMapping
org.springframework.web.servlet.handler.AbstractUrlHandlerMapping
org.springframework.web.servlet.handler.AbstractDetectingUrlHandlerMapping
org.springframework.web.servlet.mvc.support.AbstractControllerUrlHandlerMapping
org.springframework.web.servlet.mvc.support.ControllerBeanNameHandlerMapping
- All Implemented Interfaces:
- Aware, 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
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
).
- Since:
- 2.5.3
- Author:
- Juergen Hoeller
- See Also:
ControllerClassNameHandlerMapping
,
BeanNameUrlHandlerMapping
Methods inherited from class org.springframework.web.servlet.handler.AbstractUrlHandlerMapping |
buildPathExposingHandler, exposePathWithinMapping, exposeUriTemplateVariables, getHandlerInternal, getHandlerMap, getRootHandler, lookupHandler, registerHandler, registerHandler, setLazyInitHandlers, setRootHandler, supportsTypeLevelMappings, validateHandler |
Methods inherited from class org.springframework.web.servlet.handler.AbstractHandlerMapping |
adaptInterceptor, detectMappedInterceptors, extendInterceptors, getAdaptedInterceptors, getDefaultHandler, getHandler, getHandlerExecutionChain, getMappedInterceptors, getOrder, getPathMatcher, getUrlPathHelper, initInterceptors, setAlwaysUseFullPath, setDefaultHandler, setInterceptors, setOrder, setPathMatcher, setUrlDecode, setUrlPathHelper |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
ControllerBeanNameHandlerMapping
public ControllerBeanNameHandlerMapping()
setUrlPrefix
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.
setUrlSuffix
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.
buildUrlsForHandler
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
- Parameters:
beanName
- the name of the beanbeanClass
- the type of the bean
- Returns:
- the URLs determined for the bean
generatePathMapping
protected String generatePathMapping(String beanName)
- Prepends a '/' if required and appends the URL suffix to the name.