Class AbstractHandlerMapping

    • Constructor Detail

      • AbstractHandlerMapping

        public AbstractHandlerMapping()
    • Method Detail

      • setDefaultHandler

        public void setDefaultHandler(@Nullable
                                      java.lang.Object defaultHandler)
        Set the default handler for this handler mapping. This handler will be returned if no specific mapping was found.

        Default is null, indicating no default handler.

      • getDefaultHandler

        public java.lang.Object getDefaultHandler()
        Return the default handler for this handler mapping, or null if none.
      • setUrlPathHelper

        public void setUrlPathHelper(UrlPathHelper urlPathHelper)
        Set the UrlPathHelper to use for resolution of lookup paths.

        Use this to override the default UrlPathHelper with a custom subclass, or to share common UrlPathHelper settings across multiple HandlerMappings and MethodNameResolvers.

      • getUrlPathHelper

        public UrlPathHelper getUrlPathHelper()
        Return the UrlPathHelper implementation to use for resolution of lookup paths.
      • setPathMatcher

        public void setPathMatcher(PathMatcher pathMatcher)
        Set the PathMatcher implementation to use for matching URL paths against registered URL patterns. Default is AntPathMatcher.
        See Also:
      • getPathMatcher

        public PathMatcher getPathMatcher()
        Return the PathMatcher implementation to use for matching URL paths against registered URL patterns.
      • setInterceptors

        public void setInterceptors(java.lang.Object... interceptors)
        Set the interceptors to apply for all handlers mapped by this handler mapping.

        Supported interceptor types are HandlerInterceptor, WebRequestInterceptor, and MappedInterceptor. Mapped interceptors apply only to request URLs that match its path patterns. Mapped interceptor beans are also detected by type during initialization.

        interceptors - array of handler interceptors
        See Also:
        adaptInterceptor(java.lang.Object), HandlerInterceptor, WebRequestInterceptor
      • setCorsConfigurations

        public void setCorsConfigurations(java.util.Map<java.lang.String,CorsConfiguration> corsConfigurations)
        Set the "global" CORS configurations based on URL patterns. By default the first matching URL pattern is combined with the CORS configuration for the handler, if any.
        See Also:
      • setCorsConfigurationSource

        public void setCorsConfigurationSource(CorsConfigurationSource corsConfigurationSource)
        Set the "global" CORS configuration source. By default the first matching URL pattern is combined with the CORS configuration for the handler, if any.
        See Also:
      • setOrder

        public void setOrder(int order)
        Specify the order value for this HandlerMapping bean.

        The default value is Ordered.LOWEST_PRECEDENCE, meaning non-ordered.

        See Also:
      • getOrder

        public int getOrder()
        Description copied from interface: Ordered
        Get the order value of this object.

        Higher values are interpreted as lower priority. As a consequence, the object with the lowest value has the highest priority (somewhat analogous to Servlet load-on-startup values).

        Same order values will result in arbitrary sort positions for the affected objects.

        Specified by:
        getOrder in interface Ordered
        the order value
        See Also:
      • setBeanName

        public void setBeanName(java.lang.String name)
        Description copied from interface: BeanNameAware
        Set the name of the bean in the bean factory that created this bean.

        Invoked after population of normal bean properties but before an init callback such as InitializingBean.afterPropertiesSet() or a custom init-method.

        Specified by:
        setBeanName in interface BeanNameAware
        name - the name of the bean in the factory. Note that this name is the actual bean name used in the factory, which may differ from the originally specified name: in particular for inner bean names, the actual bean name might have been made unique through appending "#..." suffixes. Use the BeanFactoryUtils.originalBeanName(String) method to extract the original bean name (without suffix), if desired.
      • formatMappingName

        protected java.lang.String formatMappingName()
      • extendInterceptors

        protected void extendInterceptors(java.util.List<java.lang.Object> interceptors)
        Extension hook that subclasses can override to register additional interceptors, given the configured interceptors (see setInterceptors(java.lang.Object...)).

        Will be invoked before initInterceptors() adapts the specified interceptors into HandlerInterceptor instances.

        The default implementation is empty.

        interceptors - the configured interceptor List (never null), allowing to add further interceptors before as well as after the existing interceptors
      • getHandlerInternal

        protected abstract java.lang.Object getHandlerInternal(HttpServletRequest request)
                                                                  throws java.lang.Exception
        Look up a handler for the given request, returning null if no specific one is found. This method is called by getHandler(javax.servlet.http.HttpServletRequest); a null return value will lead to the default handler, if one is set.

        On CORS pre-flight requests this method should return a match not for the pre-flight request but for the expected actual request based on the URL path, the HTTP methods from the "Access-Control-Request-Method" header, and the headers from the "Access-Control-Request-Headers" header thus allowing the CORS configuration to be obtained via getCorsConfiguration(Object, HttpServletRequest),

        Note: This method may also return a pre-built HandlerExecutionChain, combining a handler object with dynamically determined interceptors. Statically specified interceptors will get merged into such an existing chain.

        request - current HTTP request
        the corresponding handler instance, or null if none found
        java.lang.Exception - if there is an internal error
      • getCorsConfiguration

        protected CorsConfiguration getCorsConfiguration(java.lang.Object handler,
                                                                   HttpServletRequest request)
        Retrieve the CORS configuration for the given handler.
        handler - the handler to check (never null).
        request - the current request.
        the CORS configuration for the handler, or null if none