org.springframework.web.servlet.handler
Class BeanNameUrlHandlerMapping

java.lang.Object
  extended byorg.springframework.context.support.ApplicationObjectSupport
      extended byorg.springframework.web.context.support.WebApplicationObjectSupport
          extended byorg.springframework.web.servlet.handler.AbstractHandlerMapping
              extended byorg.springframework.web.servlet.handler.AbstractUrlHandlerMapping
                  extended byorg.springframework.web.servlet.handler.BeanNameUrlHandlerMapping
All Implemented Interfaces:
ApplicationContextAware, HandlerMapping, Ordered

public class BeanNameUrlHandlerMapping
extends AbstractUrlHandlerMapping

Implementation of the HandlerMapping interface to map from URLs to beans with names that start with a slash ("/"), similar to how Struts maps URLs to action names. This is the default implementation used by the DispatcherServlet, but somewhat naive. A SimpleUrlHandlerMapping or a custom handler mapping should be used by preference.

The mapping is from URL to bean name. Thus an incoming URL "/foo" would map to a handler named "/foo", or to "/foo /foo2" in case of multiple mappings to a single handler. Note: In XML definitions, you'll need to use an alias name="/foo" in the bean definition, as the XML id may not contain slashes.

Supports direct matches (given "/test" -> registered "/test") and "*" matches (given "/test" -> registered "/t*"). Note that the default is to map within the current servlet mapping if applicable; see alwaysUseFullPath property for details.

Author:
Rod Johnson, Juergen Hoeller
See Also:
AbstractUrlHandlerMapping.setAlwaysUseFullPath(boolean), SimpleUrlHandlerMapping

Field Summary
 
Fields inherited from class org.springframework.web.servlet.handler.AbstractHandlerMapping
logger
 
Constructor Summary
BeanNameUrlHandlerMapping()
           
 
Method Summary
protected  String[] checkForUrl(String beanName)
          Check name and aliases of the given bean for URLs, detected by starting with "/".
 void initApplicationContext()
          Subclasses can override this for custom initialization behavior.
 
Methods inherited from class org.springframework.web.servlet.handler.AbstractUrlHandlerMapping
getHandlerInternal, lookupHandler, registerHandler, setAlwaysUseFullPath, setLazyInitHandlers, setUrlDecode, setUrlPathHelper
 
Methods inherited from class org.springframework.web.servlet.handler.AbstractHandlerMapping
getDefaultHandler, getHandler, getOrder, setDefaultHandler, setInterceptors, setOrder
 
Methods inherited from class org.springframework.web.context.support.WebApplicationObjectSupport
getServletContext, getTempDir, getWebApplicationContext, isContextRequired
 
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
 

Constructor Detail

BeanNameUrlHandlerMapping

public BeanNameUrlHandlerMapping()
Method Detail

initApplicationContext

public void initApplicationContext()
                            throws ApplicationContextException
Description copied from class: ApplicationObjectSupport
Subclasses can override this for custom initialization behavior. Gets called by setApplicationContext after setting the context instance.

Note: Does not get called on reinitialization of the context but rather just on first initialization of this object's context reference.

Overrides:
initApplicationContext in class ApplicationObjectSupport
Throws:
ApplicationContextException - in case of initialization errors
See Also:
ApplicationObjectSupport.setApplicationContext(org.springframework.context.ApplicationContext)

checkForUrl

protected String[] checkForUrl(String beanName)
Check name and aliases of the given bean for URLs, detected by starting with "/".



Copyright (C) 2003-2004 The Spring Framework Project.