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.resourceHandlerMapping(org.springframework.web.accept.ContentNegotiationManager, org.springframework.format.support.FormattingConversionService, org.springframework.web.servlet.resource.ResourceUrlProvider)
- Since:
- 4.0.3
- Author:
- Brian Clozel
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionaddPathPrefix
(String prefix, Predicate<Class<?>> predicate) Configure a path prefix to apply to matching controller methods.protected PathMatcher
Return the configured PathMatcher or a default, shared instance otherwise.Return thePathPatternParser
to use, if configured.Return the configured PathPatternParser or a default, shared instance otherwise.protected UrlPathHelper
Return the configured UrlPathHelper or a default, shared instance otherwise.Deprecated.Deprecated.as of 5.2.4, see deprecation note onsetUseSuffixPatternMatch(Boolean)
.Deprecated.setPathMatcher
(PathMatcher pathMatcher) Set the PathMatcher to use for String pattern matching.setPatternParser
(PathPatternParser patternParser) Enable use of parsedPathPattern
s as described inAbstractHandlerMapping.setPatternParser(PathPatternParser)
.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) Whether to match to URLs irrespective of the presence of a trailing slash.
-
Constructor Details
-
PathMatchConfigurer
public PathMatchConfigurer()
-
-
Method Details
-
setPatternParser
Enable use of parsedPathPattern
s as described inAbstractHandlerMapping.setPatternParser(PathPatternParser)
.Note: This is mutually exclusive with use of
setUrlPathHelper(UrlPathHelper)
andsetPathMatcher(PathMatcher)
.By default this is not enabled.
- Parameters:
patternParser
- the parser to pre-parse patterns with- Since:
- 5.3
-
setUseTrailingSlashMatch
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
. -
addPathPrefix
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 correspondingPredicate
. The prefix for the first matching predicate is used.Consider using
HandlerTypePredicate
to group controllers.- Parameters:
prefix
- the prefix to applypredicate
- a predicate for matching controller types- Since:
- 5.1
-
setUseSuffixPatternMatch
Deprecated.as of 5.2.4. See class-level note inRequestMappingHandlerMapping
on 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 tofalse
and 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.*".By default this is set to
false
.Note: This property is mutually exclusive with and ignored when
setPatternParser(PathPatternParser)
is set. -
setUseRegisteredSuffixPatternMatch
@Deprecated public PathMatchConfigurer setUseRegisteredSuffixPatternMatch(Boolean registeredSuffixPatternMatch) Deprecated.as of 5.2.4. See class-level note inRequestMappingHandlerMapping
on 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.By default this is set to "false".
Note: This property is mutually exclusive with and ignored when
setPatternParser(PathPatternParser)
is set. -
setUrlPathHelper
Set the UrlPathHelper to use to resolve the mapping path for the application.Note: This property is mutually exclusive with and ignored when
setPatternParser(PathPatternParser)
is set. -
setPathMatcher
Set the PathMatcher to use for String pattern matching.By default this is
AntPathMatcher
.Note: This property is mutually exclusive with and ignored when
setPatternParser(PathPatternParser)
is set. -
getPatternParser
Return thePathPatternParser
to use, if configured.- Since:
- 5.3
-
isUseTrailingSlashMatch
Deprecated. -
getPathPrefixes
-
isUseRegisteredSuffixPatternMatch
Deprecated.as of 5.2.4, see deprecation note onsetUseRegisteredSuffixPatternMatch(Boolean)
.Whether to use registered suffixes for pattern matching. -
isUseSuffixPatternMatch
Deprecated.as of 5.2.4, see deprecation note onsetUseSuffixPatternMatch(Boolean)
.Whether to use registered suffixes for pattern matching. -
getUrlPathHelper
-
getPathMatcher
-
getUrlPathHelperOrDefault
Return the configured UrlPathHelper or a default, shared instance otherwise.- Since:
- 5.3
-
getPathMatcherOrDefault
Return the configured PathMatcher or a default, shared instance otherwise.- Since:
- 5.3
-
getPatternParserOrDefault
Return the configured PathPatternParser or a default, shared instance otherwise.- Since:
- 5.3.4
-
setUseRegisteredSuffixPatternMatch(Boolean)
.