类 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
- 从以下版本开始:
- 4.0.3
- 作者:
- Brian Clozel
- 另请参阅:
RequestMappingHandlerMapping,SimpleUrlHandlerMapping
构造器概要
构造器 构造器 说明 PathMatchConfigurer()
方法概要
所有方法 实例方法 具体方法 已过时的方法 修饰符和类型 方法 说明 PathMatchConfigureraddPathPrefix(String prefix, Predicate<Class<?>> predicate)Configure a path prefix to apply to matching controller methods.PathMatchergetPathMatcher()protected Map<String,Predicate<Class<?>>>getPathPrefixes()UrlPathHelpergetUrlPathHelper()BooleanisUseRegisteredSuffixPatternMatch()已过时。as of 5.2.4.BooleanisUseSuffixPatternMatch()已过时。as of 5.2.4.BooleanisUseTrailingSlashMatch()PathMatchConfigurersetPathMatcher(PathMatcher pathMatcher)Set the PathMatcher implementation to use for matching URL paths against registered URL patterns.PathMatchConfigurersetUrlPathHelper(UrlPathHelper urlPathHelper)Set the UrlPathHelper to use for resolution of lookup paths.PathMatchConfigurersetUseRegisteredSuffixPatternMatch(Boolean registeredSuffixPatternMatch)已过时。as of 5.2.4.PathMatchConfigurersetUseSuffixPatternMatch(Boolean suffixPatternMatch)已过时。as of 5.2.4.PathMatchConfigurersetUseTrailingSlashMatch(Boolean trailingSlashMatch)Whether to match to URLs irrespective of the presence of a trailing slash.
构造器详细资料
PathMatchConfigurer
public PathMatchConfigurer()
方法详细资料
setUseSuffixPatternMatch
@Deprecated public PathMatchConfigurer setUseSuffixPatternMatch(Boolean suffixPatternMatch)
已过时。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, for the time being it's necessary to set it tofalse. In 5.3 whenfalsebecomes 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.
setUseRegisteredSuffixPatternMatch
@Deprecated public PathMatchConfigurer setUseRegisteredSuffixPatternMatch(Boolean registeredSuffixPatternMatch)
已过时。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.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.- 另请参阅:
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
@RequestMappingmethod whose controller type is matched by the correspondingPredicate. The prefix for the first matching predicate is used.Consider using
HandlerTypePredicateto group controllers.- 参数:
prefix- the prefix to applypredicate- a predicate for matching controller types- 从以下版本开始:
- 5.1
isUseSuffixPatternMatch
@Nullable @Deprecated public Boolean isUseSuffixPatternMatch()
已过时。as of 5.2.4. See class-level note inRequestMappingHandlerMappingon the deprecation of path extension config options.Whether to use registered suffixes for pattern matching.
isUseRegisteredSuffixPatternMatch
@Nullable @Deprecated public Boolean isUseRegisteredSuffixPatternMatch()
已过时。as of 5.2.4. See class-level note inRequestMappingHandlerMappingon 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()