public class ControllerBeanNameHandlerMapping extends AbstractControllerUrlHandlerMapping
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
).
ControllerClassNameHandlerMapping
,
BeanNameUrlHandlerMapping
logger
BEST_MATCHING_PATTERN_ATTRIBUTE, INTROSPECT_TYPE_LEVEL_MAPPING, MATRIX_VARIABLES_ATTRIBUTE, PATH_WITHIN_HANDLER_MAPPING_ATTRIBUTE, PRODUCIBLE_MEDIA_TYPES_ATTRIBUTE, URI_TEMPLATE_VARIABLES_ATTRIBUTE
HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE
Constructor and Description |
---|
ControllerBeanNameHandlerMapping() |
Modifier and Type | Method and Description |
---|---|
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.
|
determineUrlsForHandler, isControllerType, isEligibleForMapping, isMultiActionControllerType, setExcludedClasses, setExcludedPackages, setIncludeAnnotatedControllers
detectHandlers, initApplicationContext, setDetectHandlersInAncestorContexts
buildPathExposingHandler, exposePathWithinMapping, exposeUriTemplateVariables, getHandlerInternal, getHandlerMap, getRootHandler, lookupHandler, registerHandler, registerHandler, setLazyInitHandlers, setRootHandler, supportsTypeLevelMappings, validateHandler
adaptInterceptor, detectMappedInterceptors, extendInterceptors, getAdaptedInterceptors, getDefaultHandler, getHandler, getHandlerExecutionChain, getMappedInterceptors, getOrder, getPathMatcher, getUrlPathHelper, initInterceptors, setAlwaysUseFullPath, setDefaultHandler, setInterceptors, setOrder, setPathMatcher, setRemoveSemicolonContent, setUrlDecode, setUrlPathHelper
getServletContext, getTempDir, getWebApplicationContext, initApplicationContext, initServletContext, isContextRequired, setServletContext
getApplicationContext, getMessageSourceAccessor, requiredContextClass, setApplicationContext
public void setUrlPrefix(String urlPrefix)
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)
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)
AbstractControllerUrlHandlerMapping
buildUrlsForHandler
in class AbstractControllerUrlHandlerMapping
beanName
- the name of the beanbeanClass
- the type of the bean