org.springframework.web.servlet.mvc.method.annotation

Class RequestMappingHandlerMapping

    • Constructor Detail

      • RequestMappingHandlerMapping

        public RequestMappingHandlerMapping()
    • Method Detail

      • setUseSuffixPatternMatch

        public void setUseSuffixPatternMatch(boolean useSuffixPatternMatch)
        Whether to use suffix pattern match (".*") when matching patterns to requests. If enabled a method mapped to "/users" also matches to "/users.*".

        The default value is true.

        Also see setUseRegisteredSuffixPatternMatch(boolean) for more fine-grained control over specific suffixes to allow.

      • setUseRegisteredSuffixPatternMatch

        public void setUseRegisteredSuffixPatternMatch(boolean useRegisteredSuffixPatternMatch)
        Whether suffix pattern matching should work only against path extensions explicitly registered with the ContentNegotiationManager. This is generally recommended to reduce ambiguity and to avoid issues such as when a "." appears in the path for other reasons.

        By default this is set to "false".

      • setUseTrailingSlashMatch

        public void setUseTrailingSlashMatch(boolean useTrailingSlashMatch)
        Whether to match to URLs irrespective of the presence of a trailing slash. If enabled a method mapped to "/users" also matches to "/users/".

        The default value is true.

      • setPathPrefixes

        public void setPathPrefixes(java.util.Map<java.lang.String,java.util.function.Predicate<java.lang.Class<?>>> prefixes)
        Configure path prefixes to apply to controller methods.

        Prefixes are used to enrich the mappings of every @RequestMapping method whose controller type is matched by the corresponding Predicate. The prefix for the first matching predicate is used.

        Consider using HandlerTypePredicate to group controllers.

        Parameters:
        prefixes - a map with path prefixes as key
        Since:
        5.1
      • getPathPrefixes

        public java.util.Map<java.lang.String,java.util.function.Predicate<java.lang.Class<?>>> getPathPrefixes()
        The configured path prefixes as a read-only, possibly empty map.
        Since:
        5.1
      • useSuffixPatternMatch

        public boolean useSuffixPatternMatch()
        Whether to use suffix pattern matching.
      • useRegisteredSuffixPatternMatch

        public boolean useRegisteredSuffixPatternMatch()
        Whether to use registered suffixes for pattern matching.
      • useTrailingSlashMatch

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

        @Nullable
        public java.util.List<java.lang.String> getFileExtensions()
        Return the file extensions to use for suffix pattern matching.
      • isHandler

        protected boolean isHandler(java.lang.Class<?> beanType)
        Whether the given type is a handler with handler methods.

        Expects a handler to have either a type-level @Controller annotation or a type-level @RequestMapping annotation.

        Specified by:
        isHandler in class AbstractHandlerMethodMapping<RequestMappingInfo>
        Parameters:
        beanType - the type of the bean being checked
        Returns:
        "true" if this a handler type, "false" otherwise.
      • getCustomTypeCondition

        @Nullable
        protected RequestCondition<?> getCustomTypeCondition(java.lang.Class<?> handlerType)
        Provide a custom type-level request condition. The custom RequestCondition can be of any type so long as the same condition type is returned from all calls to this method in order to ensure custom request conditions can be combined and compared.

        Consider extending AbstractRequestCondition for custom condition types and using CompositeRequestCondition to provide multiple custom conditions.

        Parameters:
        handlerType - the handler type for which to create the condition
        Returns:
        the condition, or null
      • getCustomMethodCondition

        @Nullable
        protected RequestCondition<?> getCustomMethodCondition(java.lang.reflect.Method method)
        Provide a custom method-level request condition. The custom RequestCondition can be of any type so long as the same condition type is returned from all calls to this method in order to ensure custom request conditions can be combined and compared.

        Consider extending AbstractRequestCondition for custom condition types and using CompositeRequestCondition to provide multiple custom conditions.

        Parameters:
        method - the handler method for which to create the condition
        Returns:
        the condition, or null
      • resolveEmbeddedValuesInPatterns

        protected java.lang.String[] resolveEmbeddedValuesInPatterns(java.lang.String[] patterns)
        Resolve placeholder values in the given array of patterns.
        Returns:
        a new array with updated patterns