Class PathMatchConfigurer
- WebMvcConfigurationSupport.requestMappingHandlerMapping(org.springframework.web.accept.ContentNegotiationManager, org.springframework.format.support.FormattingConversionService, org.springframework.web.servlet.resource.ResourceUrlProvider)
- WebMvcConfigurationSupport.viewControllerHandlerMapping(org.springframework.format.support.FormattingConversionService, org.springframework.web.servlet.resource.ResourceUrlProvider)
- WebMvcConfigurationSupport.beanNameHandlerMapping(org.springframework.format.support.FormattingConversionService, org.springframework.web.servlet.resource.ResourceUrlProvider)
- WebMvcConfigurationSupport.routerFunctionMapping(org.springframework.format.support.FormattingConversionService, org.springframework.web.servlet.resource.ResourceUrlProvider)
- WebMvcConfigurationSupport.resourceHandlerMapping(org.springframework.web.accept.ContentNegotiationManager, org.springframework.format.support.FormattingConversionService, org.springframework.web.servlet.resource.ResourceUrlProvider)
- Since:
- 4.0.3
- Author:
- Brian Clozel, Rossen Stoyanchev
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionaddPathPrefix(String prefix, Predicate<Class<?>> predicate) Configure a path prefix to apply to matching controller methods.protected PathMatcherReturn the configured PathMatcher or a default, shared instance otherwise.Return thePathPatternParserto use, if configured.Return the configured PathPatternParser or a default, shared instance otherwise.protected UrlPathHelperReturn the configured UrlPathHelper or a default, shared instance otherwise.Deprecated.Deprecated.as of 5.2.4, see deprecation note onsetUseSuffixPatternMatch(Boolean).Deprecated.protected booleanWhether to preferPathMatcher.setPathMatcher(PathMatcher pathMatcher) Set the PathMatcher to use for String pattern matching.setPatternParser(PathPatternParser patternParser) Set thePathPatternParserto parsepatternswith for URL path matching.setUrlPathHelper(UrlPathHelper urlPathHelper) Set the UrlPathHelper to use to resolve the mapping path for the application.setUseRegisteredSuffixPatternMatch(Boolean registeredSuffixPatternMatch) Deprecated.as of 5.2.4.setUseSuffixPatternMatch(Boolean suffixPatternMatch) Deprecated.as of 5.2.4.setUseTrailingSlashMatch(Boolean trailingSlashMatch) Deprecated.as of 6.0, seePathPatternParser.setMatchOptionalTrailingSeparator(boolean)
- 
Constructor Details- 
PathMatchConfigurerpublic PathMatchConfigurer()
 
- 
- 
Method Details- 
setPatternParserSet thePathPatternParserto parsepatternswith for URL path matching. Parsed patterns provide a more modern and efficient alternative to String path matching viaAntPathMatcher.Note: This property is mutually exclusive with the following other, AntPathMatcherrelated properties:- setUseSuffixPatternMatch(Boolean)
- setUseRegisteredSuffixPatternMatch(Boolean)
- setUrlPathHelper(UrlPathHelper)
- setPathMatcher(PathMatcher)
 By default, as of 6.0, a PathPatternParserwith default settings is used, which enables parsedpatterns. Set this property tonullto fall back on String path matching viaAntPathMatcherinstead, or alternatively, setting one of the above listedAntPathMatcherrelated properties has the same effect.- Parameters:
- patternParser- the parser to pre-parse patterns with
- Since:
- 5.3
 
- 
setUseTrailingSlashMatch@Deprecated(since="6.0") public PathMatchConfigurer setUseTrailingSlashMatch(Boolean trailingSlashMatch) Deprecated.as of 6.0, seePathPatternParser.setMatchOptionalTrailingSeparator(boolean)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 was changed in 6.0 from truetofalsein order to support the deprecation of the property.
- 
addPathPrefixConfigure a path prefix to apply to matching controller methods.Prefixes are used to enrich the mappings of every @RequestMappingmethod whose controller type is matched by the correspondingPredicate. The prefix for the first matching predicate is used.Consider using HandlerTypePredicateto group controllers.- Parameters:
- prefix- the prefix to apply
- predicate- a predicate for matching controller types
- Since:
- 5.1
 
- 
setUseSuffixPatternMatch@Deprecated public PathMatchConfigurer setUseSuffixPatternMatch(@Nullable Boolean suffixPatternMatch) Deprecated.as of 5.2.4. See class-level note inRequestMappingHandlerMappingon the deprecation of path extension config options. As there is no replacement for this method, in 5.2.x it is necessary to set it tofalse. In 5.3 the default changes tofalseand use of this property becomes unnecessary.Whether to use suffix pattern match (".*") when matching patterns to requests. If enabled a method mapped to "/users" also matches to "/users.*".Note: This property is mutually exclusive with setPatternParser(PathPatternParser). If set, it enables use of String path matching, unless aPathPatternParseris also explicitly set in which case this property is ignored.By default this is set to false.
- 
setUseRegisteredSuffixPatternMatch@Deprecated public PathMatchConfigurer setUseRegisteredSuffixPatternMatch(@Nullable Boolean registeredSuffixPatternMatch) Deprecated.as of 5.2.4. See class-level note inRequestMappingHandlerMappingon the deprecation of path extension config options.Whether suffix pattern matching should work only against path extensions explicitly registered when youconfigure content negotiation. This is generally recommended to reduce ambiguity and to avoid issues such as when a "." appears in the path for other reasons.Note: This property is mutually exclusive with setPatternParser(PathPatternParser). If set, it enables use of String path matching, unless aPathPatternParseris also explicitly set in which case this property is ignored.By default this is set to "false". 
- 
setUrlPathHelperSet 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 aPathPatternParseris also explicitly set in which case this property is ignored.By default this is an instance of UrlPathHelperwith default settings.
- 
setPathMatcherSet 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 aPathPatternParseris also explicitly set in which case this property is ignored.By default this is an instance of AntPathMatcherwith default settings.
- 
preferPathMatcherprotected boolean preferPathMatcher()Whether to preferPathMatcher. This is the case when either is true:- PathPatternParseris explicitly set to- null.
- PathPatternParseris not explicitly set, and a- PathMatcherrelated option is explicitly set.
 - Since:
- 6.0
 
- 
getPatternParserReturn thePathPatternParserto use, if configured.- Since:
- 5.3
 
- 
isUseTrailingSlashMatchDeprecated.
- 
getPathPrefixes
- 
isUseRegisteredSuffixPatternMatchDeprecated.as of 5.2.4, see deprecation note onsetUseRegisteredSuffixPatternMatch(Boolean).Whether to use registered suffixes for pattern matching.
- 
isUseSuffixPatternMatchDeprecated.as of 5.2.4, see deprecation note onsetUseSuffixPatternMatch(Boolean).Whether to use registered suffixes for pattern matching.
- 
getUrlPathHelper
- 
getPathMatcher
- 
getUrlPathHelperOrDefaultReturn the configured UrlPathHelper or a default, shared instance otherwise.- Since:
- 5.3
 
- 
getPathMatcherOrDefaultReturn the configured PathMatcher or a default, shared instance otherwise.- Since:
- 5.3
 
- 
getPatternParserOrDefaultReturn the configured PathPatternParser or a default, shared instance otherwise.- Since:
- 5.3.4
 
 
- 
setUseRegisteredSuffixPatternMatch(Boolean).