Class PathMatchConfigurer

java.lang.Object
org.springframework.web.servlet.config.annotation.PathMatchConfigurer

  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    addPathPrefix(String prefix, Predicate<Class<?>> predicate)
    Configure a path prefix to apply to matching controller methods.
    @Nullable org.springframework.util.PathMatcher
    Deprecated, for removal: This API element is subject to removal in a future version.
    protected org.springframework.util.PathMatcher
    Deprecated, for removal: This API element is subject to removal in a future version.
    use of PathMatcher is deprecated for use at runtime in web modules in favor of parsed patterns with PathPatternParser.
     
    @Nullable org.springframework.web.util.pattern.PathPatternParser
    Return the PathPatternParser to use, if configured.
    org.springframework.web.util.pattern.PathPatternParser
    Return the configured PathPatternParser or a default, shared instance otherwise.
    @Nullable org.springframework.web.util.UrlPathHelper
    Deprecated, for removal: This API element is subject to removal in a future version.
    protected org.springframework.web.util.UrlPathHelper
    Deprecated, for removal: This API element is subject to removal in a future version.
    use of PathMatcher and UrlPathHelper is deprecated for use at runtime in web modules in favor of parsed patterns with PathPatternParser.
    protected boolean
    Deprecated, for removal: This API element is subject to removal in a future version.
    use of PathMatcher is deprecated for use at runtime in web modules in favor of parsed patterns with PathPatternParser.
    setPathMatcher(org.springframework.util.PathMatcher pathMatcher)
    Deprecated, for removal: This API element is subject to removal in a future version.
    use of PathMatcher is deprecated for use at runtime in web modules in favor of parsed patterns with PathPatternParser.
    setPatternParser(@Nullable org.springframework.web.util.pattern.PathPatternParser patternParser)
    Set the PathPatternParser to parse patterns with for URL path matching.
    setUrlPathHelper(org.springframework.web.util.UrlPathHelper urlPathHelper)
    Deprecated, for removal: This API element is subject to removal in a future version.
    use of PathMatcher and UrlPathHelper is deprecated for use at runtime in web modules in favor of parsed patterns with PathPatternParser.

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • PathMatchConfigurer

      public PathMatchConfigurer()
  • Method Details

    • setPatternParser

      public PathMatchConfigurer setPatternParser(@Nullable org.springframework.web.util.pattern.PathPatternParser patternParser)
      Set the PathPatternParser to parse patterns with for URL path matching. Parsed patterns provide a more modern and efficient alternative to String path matching via AntPathMatcher.

      By default, as of 6.0, a PathPatternParser with default settings is used, which enables parsed patterns. Set this property to null to fall back on String path matching via AntPathMatcher instead, or alternatively, setting one of the above listed AntPathMatcher related properties has the same effect.

      Parameters:
      patternParser - the parser to pre-parse patterns with
      Since:
      5.3
    • addPathPrefix

      public PathMatchConfigurer addPathPrefix(String prefix, Predicate<Class<?>> predicate)
      Configure a path prefix to apply to matching 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:
      prefix - the prefix to apply
      predicate - a predicate for matching controller types
      Since:
      5.1
    • setUrlPathHelper

      @Deprecated(since="7.0", forRemoval=true) public PathMatchConfigurer setUrlPathHelper(org.springframework.web.util.UrlPathHelper urlPathHelper)
      Deprecated, for removal: This API element is subject to removal in a future version.
      use of PathMatcher and UrlPathHelper is deprecated for use at runtime in web modules in favor of parsed patterns with PathPatternParser.
      Set the UrlPathHelper to use to resolve the mapping path for the application.

      Note: This property is mutually exclusive with setPatternParser(PathPatternParser). If set, it enables use of String path matching, unless a PathPatternParser is also explicitly set in which case this property is ignored.

      By default, this is an instance of UrlPathHelper with default settings.

    • setPathMatcher

      @Deprecated(since="7.0", forRemoval=true) public PathMatchConfigurer setPathMatcher(org.springframework.util.PathMatcher pathMatcher)
      Deprecated, for removal: This API element is subject to removal in a future version.
      use of PathMatcher is deprecated for use at runtime in web modules in favor of parsed patterns with PathPatternParser.
      Set the PathMatcher to use for String pattern matching.

      Note: This property is mutually exclusive with setPatternParser(PathPatternParser). If set, it enables use of String path matching, unless a PathPatternParser is also explicitly set in which case this property is ignored.

      By default, this is an instance of AntPathMatcher with default settings.

    • preferPathMatcher

      @Deprecated(since="7.0", forRemoval=true) protected boolean preferPathMatcher()
      Deprecated, for removal: This API element is subject to removal in a future version.
      use of PathMatcher is deprecated for use at runtime in web modules in favor of parsed patterns with PathPatternParser.
      Whether to prefer PathMatcher. This is the case when either is true:
      • PathPatternParser is explicitly set to null.
      • PathPatternParser is not explicitly set, and a PathMatcher related option is explicitly set.
      Since:
      6.0
    • getPatternParser

      public @Nullable org.springframework.web.util.pattern.PathPatternParser getPatternParser()
      Return the PathPatternParser to use, if configured.
      Since:
      5.3
    • getPathPrefixes

      protected @Nullable Map<String, Predicate<Class<?>>> getPathPrefixes()
    • getUrlPathHelper

      @Deprecated(since="7.0", forRemoval=true) public @Nullable org.springframework.web.util.UrlPathHelper getUrlPathHelper()
      Deprecated, for removal: This API element is subject to removal in a future version.
    • getPathMatcher

      @Deprecated(since="7.0", forRemoval=true) public @Nullable org.springframework.util.PathMatcher getPathMatcher()
      Deprecated, for removal: This API element is subject to removal in a future version.
    • getUrlPathHelperOrDefault

      @Deprecated(since="7.0", forRemoval=true) protected org.springframework.web.util.UrlPathHelper getUrlPathHelperOrDefault()
      Deprecated, for removal: This API element is subject to removal in a future version.
      use of PathMatcher and UrlPathHelper is deprecated for use at runtime in web modules in favor of parsed patterns with PathPatternParser.
      Return the configured UrlPathHelper or a default, shared instance otherwise.
      Since:
      5.3
    • getPathMatcherOrDefault

      @Deprecated(since="7.0", forRemoval=true) protected org.springframework.util.PathMatcher getPathMatcherOrDefault()
      Deprecated, for removal: This API element is subject to removal in a future version.
      use of PathMatcher is deprecated for use at runtime in web modules in favor of parsed patterns with PathPatternParser.
      Return the configured PathMatcher or a default, shared instance otherwise.
      Since:
      5.3
    • getPatternParserOrDefault

      public org.springframework.web.util.pattern.PathPatternParser getPatternParserOrDefault()
      Return the configured PathPatternParser or a default, shared instance otherwise.
      Since:
      5.3.4