public class PathMatchConfigurer extends Object
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)
Constructor and Description |
---|
PathMatchConfigurer() |
Modifier and Type | Method and Description |
---|---|
PathMatchConfigurer |
addPathPrefix(String prefix,
Predicate<Class<?>> predicate)
Configure a path prefix to apply to matching controller methods.
|
PathMatcher |
getPathMatcher() |
protected PathMatcher |
getPathMatcherOrDefault()
Return the configured PathMatcher or a default, shared instance otherwise.
|
protected Map<String,Predicate<Class<?>>> |
getPathPrefixes() |
PathPatternParser |
getPatternParser()
Return the
PathPatternParser to use, if configured. |
PathPatternParser |
getPatternParserOrDefault()
Return the configured PathPatternParser or a default, shared instance otherwise.
|
UrlPathHelper |
getUrlPathHelper() |
protected UrlPathHelper |
getUrlPathHelperOrDefault()
Return the configured UrlPathHelper or a default, shared instance otherwise.
|
Boolean |
isUseRegisteredSuffixPatternMatch()
Deprecated.
as of 5.2.4, see deprecation note on
setUseRegisteredSuffixPatternMatch(Boolean) . |
Boolean |
isUseSuffixPatternMatch()
Deprecated.
as of 5.2.4, see deprecation note on
setUseSuffixPatternMatch(Boolean) . |
Boolean |
isUseTrailingSlashMatch()
Deprecated.
|
PathMatchConfigurer |
setPathMatcher(PathMatcher pathMatcher)
Set the PathMatcher to use for String pattern matching.
|
PathMatchConfigurer |
setPatternParser(PathPatternParser patternParser)
Enable use of parsed
PathPattern s as described in
AbstractHandlerMapping.setPatternParser(PathPatternParser) . |
PathMatchConfigurer |
setUrlPathHelper(UrlPathHelper urlPathHelper)
Set the UrlPathHelper to use to resolve the mapping path for the application.
|
PathMatchConfigurer |
setUseRegisteredSuffixPatternMatch(Boolean registeredSuffixPatternMatch)
Deprecated.
as of 5.2.4. See class-level note in
RequestMappingHandlerMapping on the deprecation of path extension
config options. |
PathMatchConfigurer |
setUseSuffixPatternMatch(Boolean suffixPatternMatch)
Deprecated.
as of 5.2.4. See class-level note in
RequestMappingHandlerMapping 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 to false . In 5.3 the default changes to
false and use of this property becomes unnecessary. |
PathMatchConfigurer |
setUseTrailingSlashMatch(Boolean trailingSlashMatch)
Whether to match to URLs irrespective of the presence of a trailing slash.
|
public PathMatchConfigurer setPatternParser(PathPatternParser patternParser)
PathPattern
s as described in
AbstractHandlerMapping.setPatternParser(PathPatternParser)
.
Note: This is mutually exclusive with use of
setUrlPathHelper(UrlPathHelper)
and
setPathMatcher(PathMatcher)
.
By default this is not enabled.
patternParser
- the parser to pre-parse patterns withpublic PathMatchConfigurer setUseTrailingSlashMatch(Boolean trailingSlashMatch)
The default value is true
.
public PathMatchConfigurer addPathPrefix(String prefix, Predicate<Class<?>> predicate)
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.
prefix
- the prefix to applypredicate
- a predicate for matching controller types@Deprecated public PathMatchConfigurer setUseSuffixPatternMatch(Boolean suffixPatternMatch)
RequestMappingHandlerMapping
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 to false
. In 5.3 the default changes to
false
and use of this property becomes unnecessary.By default this is set to true
.
Note: This property is mutually exclusive with and
ignored when setPatternParser(PathPatternParser)
is set.
@Deprecated public PathMatchConfigurer setUseRegisteredSuffixPatternMatch(Boolean registeredSuffixPatternMatch)
RequestMappingHandlerMapping
on the deprecation of path extension
config options.configure 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.
public PathMatchConfigurer setUrlPathHelper(UrlPathHelper urlPathHelper)
Note: This property is mutually exclusive with and
ignored when setPatternParser(PathPatternParser)
is set.
public PathMatchConfigurer setPathMatcher(PathMatcher pathMatcher)
By default this is AntPathMatcher
.
Note: This property is mutually exclusive with and
ignored when setPatternParser(PathPatternParser)
is set.
@Nullable public PathPatternParser getPatternParser()
PathPatternParser
to use, if configured.@Nullable @Deprecated public Boolean isUseTrailingSlashMatch()
@Nullable @Deprecated public Boolean isUseRegisteredSuffixPatternMatch()
setUseRegisteredSuffixPatternMatch(Boolean)
.@Nullable @Deprecated public Boolean isUseSuffixPatternMatch()
setUseSuffixPatternMatch(Boolean)
.@Nullable public UrlPathHelper getUrlPathHelper()
@Nullable public PathMatcher getPathMatcher()
protected UrlPathHelper getUrlPathHelperOrDefault()
protected PathMatcher getPathMatcherOrDefault()
public PathPatternParser getPatternParserOrDefault()