public class

ControllerBeanNameHandlerMapping

extends AbstractControllerUrlHandlerMapping
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

Class Overview

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).

Summary

[Expand]
Inherited Constants
From interface org.springframework.core.Ordered
[Expand]
Inherited Fields
From class org.springframework.context.support.ApplicationObjectSupport
From interface org.springframework.web.servlet.HandlerMapping
Public Constructors
ControllerBeanNameHandlerMapping()
Public Methods
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.
Protected Methods
String[] buildUrlsForHandler(String beanName, Class beanClass)
Abstract template method to be implemented by subclasses.
String generatePathMapping(String beanName)
Prepends a '/' if required and appends the URL suffix to the name.
[Expand]
Inherited Methods
From class org.springframework.web.servlet.mvc.support.AbstractControllerUrlHandlerMapping
From class org.springframework.web.servlet.handler.AbstractDetectingUrlHandlerMapping
From class org.springframework.web.servlet.handler.AbstractUrlHandlerMapping
From class org.springframework.web.servlet.handler.AbstractHandlerMapping
From class org.springframework.web.context.support.WebApplicationObjectSupport
From class org.springframework.context.support.ApplicationObjectSupport
From class java.lang.Object
From interface org.springframework.context.ApplicationContextAware
From interface org.springframework.core.Ordered
From interface org.springframework.web.context.ServletContextAware
From interface org.springframework.web.servlet.HandlerMapping

Public Constructors

public ControllerBeanNameHandlerMapping ()

Public Methods

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 Methods

protected String[] buildUrlsForHandler (String beanName, Class beanClass)

Abstract template method to be implemented by subclasses.

Parameters
beanName the name of the bean
beanClass the type of the bean
Returns
  • the URLs determined for the bean

protected String generatePathMapping (String beanName)

Prepends a '/' if required and appends the URL suffix to the name.