|
The Spring Framework | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
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
public abstract class AbstractUrlHandlerMapping
Abstract base class for URL-mapped HandlerMapping
implementations. Provides infrastructure for mapping handlers to URLs and configurable
URL lookup. For information on the latter, see "alwaysUseFullPath" property.
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 details, see the
AntPathMatcher
javadoc.
Will search all path patterns to find the most exact match for the current request path. The most exact match is defined as the longest path pattern that matches the current request path.
setAlwaysUseFullPath(boolean)
,
setUrlDecode(boolean)
,
AntPathMatcher
Field Summary |
---|
Fields inherited from class org.springframework.context.support.ApplicationObjectSupport |
---|
logger |
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 | |
---|---|
AbstractUrlHandlerMapping()
|
Method Summary | |
---|---|
protected void |
exposePathWithinMapping(String pathWithinMapping,
HttpServletRequest request)
Expose the path within the current mapping as request attribute. |
protected Object |
getHandlerInternal(HttpServletRequest request)
Look up a handler for the URL path of the given request. |
Map |
getHandlerMap()
Return the registered handlers as an unmodifiable Map, with the registered path as key and the handler object (or handler bean name in case of a lazy-init handler) as value. |
Object |
getRootHandler()
Return the root handler for this handler mapping (registered for "/"), or null if none. |
protected Object |
lookupHandler(String urlPath,
HttpServletRequest request)
Look up a handler instance for the given URL path. |
protected void |
registerHandler(String[] urlPaths,
String beanName)
Register the specified handler for the given URL paths. |
protected void |
registerHandler(String urlPath,
Object handler)
Register the specified handler for the given URL path. |
void |
setAlwaysUseFullPath(boolean alwaysUseFullPath)
Set if URL lookup should always use the full path within the current servlet context. |
void |
setLazyInitHandlers(boolean lazyInitHandlers)
Set whether to lazily initialize handlers. |
void |
setPathMatcher(PathMatcher pathMatcher)
Set the PathMatcher implementation to use for matching URL paths against registered URL patterns. |
void |
setRootHandler(Object rootHandler)
Set the root handler for this handler mapping, that is, the handler to be registered for the root path ("/"). |
void |
setUrlDecode(boolean urlDecode)
Set if context path and request URI should be URL-decoded. |
void |
setUrlPathHelper(UrlPathHelper urlPathHelper)
Set the UrlPathHelper to use for resolution of lookup paths. |
Methods inherited from class org.springframework.web.servlet.handler.AbstractHandlerMapping |
---|
adaptInterceptor, extendInterceptors, getAdaptedInterceptors, getDefaultHandler, getHandler, getHandlerExecutionChain, getOrder, initApplicationContext, 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 |
Constructor Detail |
---|
public AbstractUrlHandlerMapping()
Method Detail |
---|
public void setAlwaysUseFullPath(boolean alwaysUseFullPath)
Default is "false".
UrlPathHelper.setAlwaysUseFullPath(boolean)
public void setUrlDecode(boolean urlDecode)
Uses either the request encoding or the default encoding according to the Servlet spec (ISO-8859-1).
Note: Setting this to "true" requires JDK 1.4 if the encoding differs from the VM's platform default encoding, as JDK 1.3's URLDecoder class does not offer a way to specify the encoding.
UrlPathHelper.setUrlDecode(boolean)
public void setUrlPathHelper(UrlPathHelper urlPathHelper)
Use this to override the default UrlPathHelper with a custom subclass, or to share common UrlPathHelper settings across multiple HandlerMappings and MethodNameResolvers.
AbstractUrlMethodNameResolver.setUrlPathHelper(org.springframework.web.util.UrlPathHelper)
public void setPathMatcher(PathMatcher pathMatcher)
AntPathMatcher
public void setRootHandler(Object rootHandler)
Default is null
, indicating no root handler.
public Object getRootHandler()
null
if none.
public void setLazyInitHandlers(boolean lazyInitHandlers)
If you want to allow your controllers to be lazily initialized, make them "lazy-init" and set this flag to true. Just making them "lazy-init" will not work, as they are initialized through the references from the handler mapping in this case.
protected Object getHandlerInternal(HttpServletRequest request) throws Exception
getHandlerInternal
in class AbstractHandlerMapping
request
- current HTTP request
null
if none found
Exception
- if there is an internal errorprotected Object lookupHandler(String urlPath, HttpServletRequest request)
Supports direct matches, e.g. a registered "/test" matches "/test", and various Ant-style pattern matches, e.g. a registered "/t*" matches both "/test" and "/team". For details, see the AntPathMatcher class.
Looks for the most exact pattern, where most exact is defined as the longest path pattern.
urlPath
- URL the bean is mapped torequest
- current HTTP request (to expose the path within the mapping to)
null
if not foundexposePathWithinMapping(java.lang.String, javax.servlet.http.HttpServletRequest)
,
AntPathMatcher
protected void exposePathWithinMapping(String pathWithinMapping, HttpServletRequest request)
pathWithinMapping
- the path within the current mappingrequest
- the request to expose the path toHandlerMapping.PATH_WITHIN_HANDLER_MAPPING_ATTRIBUTE
protected void registerHandler(String[] urlPaths, String beanName) throws BeansException, IllegalStateException
urlPaths
- the URLs that the bean should be mapped tobeanName
- the name of the handler bean
BeansException
- if the handler couldn't be registered
IllegalStateException
- if there is a conflicting handler registeredprotected void registerHandler(String urlPath, Object handler) throws BeansException, IllegalStateException
urlPath
- the URL the bean should be mapped tohandler
- the handler instance or handler bean name String
(a bean name will automatically be resolved into the corrresponding handler bean)
BeansException
- if the handler couldn't be registered
IllegalStateException
- if there is a conflicting handler registeredpublic final Map getHandlerMap()
AbstractHandlerMapping.getDefaultHandler()
|
The Spring Framework | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |