Class PathMatchConfigurer
- java.lang.Object
- org.springframework.web.servlet.config.annotation.PathMatchConfigurer
public class PathMatchConfigurer extends Object
Helps with configuring HandlerMappings path matching options such as trailing slash match, suffix registration, path matcher and path helper.Configured path matcher and path helper instances are shared for:
- RequestMappings
- ViewControllerMappings
- ResourcesMappings
- Since:
- 4.0.3
- Author:
- Brian Clozel
- See Also:
RequestMappingHandlerMapping
,SimpleUrlHandlerMapping
Constructor Summary
Constructors Constructor Description PathMatchConfigurer()
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description PathMatchConfigurer
addPathPrefix(String prefix, Predicate<Class<?>> predicate)
Configure a path prefix to apply to matching controller methods.PathMatcher
getPathMatcher()
protected Map<String,Predicate<Class<?>>>
getPathPrefixes()
UrlPathHelper
getUrlPathHelper()
Boolean
isUseRegisteredSuffixPatternMatch()
Deprecated.as of 5.2.4.Boolean
isUseSuffixPatternMatch()
Deprecated.as of 5.2.4.Boolean
isUseTrailingSlashMatch()
PathMatchConfigurer
setPathMatcher(PathMatcher pathMatcher)
Set the PathMatcher implementation to use for matching URL paths against registered URL patterns.PathMatchConfigurer
setUrlPathHelper(UrlPathHelper urlPathHelper)
Set the UrlPathHelper to use for resolution of lookup paths.PathMatchConfigurer
setUseRegisteredSuffixPatternMatch(Boolean registeredSuffixPatternMatch)
Deprecated.as of 5.2.4.PathMatchConfigurer
setUseSuffixPatternMatch(Boolean suffixPatternMatch)
Deprecated.as of 5.2.4.PathMatchConfigurer
setUseTrailingSlashMatch(Boolean trailingSlashMatch)
Whether to match to URLs irrespective of the presence of a trailing slash.
Constructor Detail
PathMatchConfigurer
public PathMatchConfigurer()
Method Detail
setUseSuffixPatternMatch
@Deprecated public PathMatchConfigurer setUseSuffixPatternMatch(Boolean suffixPatternMatch)
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, for the time being it's necessary to set it tofalse
. In 5.3 whenfalse
becomes the default, use of this property will no longer be necessary.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
true
.- See Also:
registeredSuffixPatternMatch
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".
setUseTrailingSlashMatch
public PathMatchConfigurer setUseTrailingSlashMatch(Boolean trailingSlashMatch)
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
.
setUrlPathHelper
public PathMatchConfigurer 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.
setPathMatcher
public PathMatchConfigurer setPathMatcher(PathMatcher pathMatcher)
Set the PathMatcher implementation to use for matching URL paths against registered URL patterns. Default is AntPathMatcher.- See Also:
AntPathMatcher
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 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
isUseSuffixPatternMatch
@Nullable @Deprecated public Boolean isUseSuffixPatternMatch()
Deprecated.as of 5.2.4. See class-level note inRequestMappingHandlerMapping
on the deprecation of path extension config options.Whether to use registered suffixes for pattern matching.
isUseRegisteredSuffixPatternMatch
@Nullable @Deprecated public Boolean isUseRegisteredSuffixPatternMatch()
Deprecated.as of 5.2.4. See class-level note inRequestMappingHandlerMapping
on the deprecation of path extension config options.Whether to use registered suffixes for pattern matching.
isUseTrailingSlashMatch
@Nullable public Boolean isUseTrailingSlashMatch()
getUrlPathHelper
@Nullable public UrlPathHelper getUrlPathHelper()
getPathMatcher
@Nullable public PathMatcher getPathMatcher()