|
The Spring Framework | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.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.mvc.support.ControllerClassNameHandlerMapping
public class ControllerClassNameHandlerMapping
Implementation of HandlerMapping that follows a simple convention for
generating URL path mappings from the class names of registered
Controller and
ThrowawayController beans.
For simple Controller implementations
(those that handle a single request type), the convention is to take the
short name of the Class,
remove the 'Controller' suffix if it exists and return the remaining text, lowercased,
as the mapping, with a leading /. For example:
WelcomeController -> /welcome*HomeController -> /home*For MultiActionControllers then a similar mapping is registered,
except that all sub-paths are registed using the trailing wildcard pattern /*.
For example:
WelcomeController -> /welcome/*CatalogController -> /catalog/*For MultiActionController it is often useful to use
this mapping strategy in conjunction with the
InternalPathMethodNameResolver.
Controller,
ThrowawayController,
MultiActionController| Field Summary | |
|---|---|
protected Log |
logger
Logger available to subclasses |
| Fields inherited from interface org.springframework.web.servlet.HandlerMapping |
|---|
PATH_WITHIN_HANDLER_MAPPING_ATTRIBUTE |
| Fields inherited from interface org.springframework.core.Ordered |
|---|
HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE |
| Constructor Summary | |
|---|---|
ControllerClassNameHandlerMapping()
|
|
| Method Summary | |
|---|---|
protected void |
detectControllers()
Detect all the Controller and
ThrowawayController
beans registered in the ApplicationContext
and register a URL path mapping for each one based on rules defined here. |
protected String |
generatePathMapping(Class controllerClass)
Generate the actual URL path for the given Controller class. |
protected void |
initApplicationContext()
Calls the detectControllers() method in addition
to the superclass's initialization. |
protected void |
registerController(String beanName)
Register the controller with the given name, as defined in the current application context. |
protected void |
registerControllers(Class controllerType)
Register all controllers of the given type, searching the current DispatcherServlet's ApplicationContext for matching beans. |
| Methods inherited from class org.springframework.web.servlet.handler.AbstractUrlHandlerMapping |
|---|
exposePathWithinMapping, getHandlerInternal, getHandlerMap, lookupHandler, registerHandler, registerHandler, setAlwaysUseFullPath, setLazyInitHandlers, setPathMatcher, setUrlDecode, setUrlPathHelper |
| Methods inherited from class org.springframework.web.servlet.handler.AbstractHandlerMapping |
|---|
adaptInterceptor, getDefaultHandler, getHandler, getOrder, initInterceptors, setDefaultHandler, setInterceptors, setOrder |
| Methods inherited from class org.springframework.web.context.support.WebApplicationObjectSupport |
|---|
getServletContext, getTempDir, getWebApplicationContext, 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 |
| Methods inherited from interface org.springframework.web.servlet.HandlerMapping |
|---|
getHandler |
| Field Detail |
|---|
protected final Log logger
| Constructor Detail |
|---|
public ControllerClassNameHandlerMapping()
| Method Detail |
|---|
protected void initApplicationContext()
detectControllers() method in addition
to the superclass's initialization.
initApplicationContext in class AbstractHandlerMappingdetectControllers()
protected void detectControllers()
throws BeansException
Controller and
ThrowawayController
beans registered in the ApplicationContext
and register a URL path mapping for each one based on rules defined here.
BeansException - if the controllers couldn't be obtained or registeredgeneratePathMapping(Class)
protected void registerControllers(Class controllerType)
throws BeansException
controllerType - the type of controller to search for
BeansException - if the controllers couldn't be obtained or registered
protected void registerController(String beanName)
throws BeansException,
IllegalStateException
beanName - the name of the controller bean
BeansException - if the controller couldn't be registered
IllegalStateException - if there is a conflicting handler registeredApplicationObjectSupport.getApplicationContext()protected String generatePathMapping(Class controllerClass)
Controller class. Sub-classes
may choose to customize the paths that are generated by overriding this method.
|
The Spring Framework | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||