org.springframework.web.servlet.handler
Class SimpleUrlHandlerMapping
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.SimpleUrlHandlerMapping
- All Implemented Interfaces:
- ApplicationContextAware, Ordered, ServletContextAware, HandlerMapping
public class SimpleUrlHandlerMapping
- extends AbstractUrlHandlerMapping
Implementation of the HandlerMapping interface to map from URLs to
request handler beans. Supports both mapping to bean instances and
mapping to bean names: The latter is required for prototype handlers.
The "urlMap" property is suitable for populating the handler map
with bean references, e.g. via the map element in XML bean definitions.
Mappings to bean names can be set via the "mappings" property, in a
form accepted by the java.util.Properties class, like as follows:
/welcome.html=ticketController
/show.html=ticketController
The syntax is PATH=HANDLER_BEAN_NAME
.
If the path doesn't begin with a slash, one is prepended.
Supports direct matches, e.g. a registered "/test" matches "/test",
and various Ant-style pattern matches, e.g. a registered "/t*" pattern
matches both "/test" and "/team", "/test/*" matches all paths in the
"/test" directory, "/test/**" matches all paths below "/test".
For syntax details, see the AntPathMatcher class.
- Author:
- Rod Johnson, Juergen Hoeller
- See Also:
DispatcherServlet
,
AntPathMatcher
,
Properties
Method Summary |
void |
initApplicationContext()
Calls the registerHandlers method in addition
to the superclass's initialization. |
protected void |
registerHandlers(Map urlMap)
Register all handlers specified in the URL map for the corresponding paths. |
void |
setMappings(Properties mappings)
Map URL paths to handler bean names. |
void |
setUrlMap(Map urlMap)
Set a Map with URL paths as keys and handler beans as values. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
SimpleUrlHandlerMapping
public SimpleUrlHandlerMapping()
setMappings
public void setMappings(Properties mappings)
- Map URL paths to handler bean names.
This is the typical way of configuring this HandlerMapping.
Supports direct URL matches and Ant-style pattern matches.
For syntax details, see the AntPathMatcher class.
- Parameters:
mappings
- properties with URLs as keys and bean names as values- See Also:
AntPathMatcher
setUrlMap
public void setUrlMap(Map urlMap)
- Set a Map with URL paths as keys and handler beans as values.
Convenient for population with bean references.
Supports direct URL matches and Ant-style pattern matches.
For syntax details, see the AntPathMatcher class.
- Parameters:
urlMap
- map with URLs as keys and beans as values- See Also:
AntPathMatcher
initApplicationContext
public void initApplicationContext()
throws BeansException
- Calls the
registerHandlers
method in addition
to the superclass's initialization.
- Overrides:
initApplicationContext
in class AbstractHandlerMapping
- Throws:
ApplicationContextException
- in case of initialization errors
BeansException
- if thrown by ApplicationContext methods- See Also:
registerHandlers(java.util.Map)
registerHandlers
protected void registerHandlers(Map urlMap)
throws BeansException
- Register all handlers specified in the URL map for the corresponding paths.
- Parameters:
urlMap
- Map with URL paths as keys and handler beans or bean names as values
- Throws:
BeansException
- if a handler couldn't be registered
IllegalStateException
- if there is a conflicting handler registered
Copyright © 2002-2006 The Spring Framework.