类 AbstractUrlHandlerMapping

    • 方法详细资料

      • setRootHandler

        public void setRootHandler​(Object rootHandler)
        Set the root handler for this handler mapping, that is, the handler to be registered for the root path ("/").

        Default is null, indicating no root handler.

      • getRootHandler

        public Object getRootHandler()
        Return the root handler for this handler mapping (registered for "/"), or null if none.
      • setUseTrailingSlashMatch

        public void setUseTrailingSlashMatch​(boolean useTrailingSlashMatch)
        Whether to match to URLs irrespective of the presence of a trailing slash. If enabled a URL pattern such as "/users" also matches to "/users/".

        The default value is false.

      • useTrailingSlashMatch

        public boolean useTrailingSlashMatch()
        Whether to match to URLs irrespective of the presence of a trailing slash.
      • setLazyInitHandlers

        public void setLazyInitHandlers​(boolean lazyInitHandlers)
        Set whether to lazily initialize handlers. Only applicable to singleton handlers, as prototypes are always lazily initialized. Default is "false", as eager initialization allows for more efficiency through referencing the controller objects directly.

        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.

      • validateHandler

        protected void validateHandler​(Object handler,
                                       HttpServletRequest request)
                                throws Exception
        Validate the given handler against the current request.

        The default implementation is empty. Can be overridden in subclasses, for example to enforce specific preconditions expressed in URL mappings.

        参数:
        handler - the handler object to validate
        request - current HTTP request
        抛出:
        Exception - if validation failed
      • registerHandler

        protected void registerHandler​(String urlPath,
                                       Object handler)
                                throws BeansException,
                                       IllegalStateException
        Register the specified handler for the given URL path.
        参数:
        urlPath - the URL the bean should be mapped to
        handler - the handler instance or handler bean name String (a bean name will automatically be resolved into the corresponding handler bean)
        抛出:
        BeansException - if the handler couldn't be registered
        IllegalStateException - if there is a conflicting handler registered
      • supportsTypeLevelMappings

        protected boolean supportsTypeLevelMappings()
        Indicates whether this handler mapping support type-level mappings. Default to false.