类 PathPatternParser
- java.lang.Object
- org.springframework.web.util.pattern.PathPatternParser
public class PathPatternParser extends Object
Parser for URI path patterns producingPathPattern
instances that can then be matched to requests.The
PathPatternParser
andPathPattern
are specifically designed for use with HTTP URL paths in web applications where a large number of URI path patterns, continuously matched against incoming requests, motivates the need for efficient matching.For details of the path pattern syntax see
PathPattern
.- 从以下版本开始:
- 5.0
- 作者:
- Andy Clement
字段概要
字段 修饰符和类型 字段 说明 static PathPatternParser
defaultInstance
Shared, read-only instance ofPathPatternParser
.
构造器概要
构造器 构造器 说明 PathPatternParser()
方法概要
所有方法 实例方法 具体方法 修饰符和类型 方法 说明 PathContainer.Options
getPathOptions()
Return theconfigured
pattern parsing options.boolean
isCaseSensitive()
Whether case-sensitive pattern matching is enabled.boolean
isMatchOptionalTrailingSeparator()
Whether optional trailing slashing match is enabled.PathPattern
parse(String pathPattern)
Process the path pattern content, a character at a time, breaking it into path elements around separator boundaries and verifying the structure at each stage.void
setCaseSensitive(boolean caseSensitive)
Whether path pattern matching should be case-sensitive.void
setMatchOptionalTrailingSeparator(boolean matchOptionalTrailingSeparator)
Whether aPathPattern
produced by this parser should automatically match request paths with a trailing slash.void
setPathOptions(PathContainer.Options pathOptions)
Set options for parsing patterns.
字段详细资料
defaultInstance
public static final PathPatternParser defaultInstance
Shared, read-only instance ofPathPatternParser
. Uses default settings:matchOptionalTrailingSeparator=true
caseSensitivetrue
pathOptions=PathContainer.Options.HTTP_PATH
构造器详细资料
PathPatternParser
public PathPatternParser()
方法详细资料
setMatchOptionalTrailingSeparator
public void setMatchOptionalTrailingSeparator(boolean matchOptionalTrailingSeparator)
Whether aPathPattern
produced by this parser should automatically match request paths with a trailing slash.If set to
true
aPathPattern
without a trailing slash will also match request paths with a trailing slash. If set tofalse
aPathPattern
will only match request paths with a trailing slash.The default is
true
.
isMatchOptionalTrailingSeparator
public boolean isMatchOptionalTrailingSeparator()
Whether optional trailing slashing match is enabled.
setCaseSensitive
public void setCaseSensitive(boolean caseSensitive)
Whether path pattern matching should be case-sensitive.The default is
true
.
isCaseSensitive
public boolean isCaseSensitive()
Whether case-sensitive pattern matching is enabled.
setPathOptions
public void setPathOptions(PathContainer.Options pathOptions)
Set options for parsing patterns. These should be the same as the options used to parse input paths.PathContainer.Options.HTTP_PATH
is used by default.- 从以下版本开始:
- 5.2
getPathOptions
public PathContainer.Options getPathOptions()
Return theconfigured
pattern parsing options.- 从以下版本开始:
- 5.2
parse
public PathPattern parse(String pathPattern) throws PatternParseException
Process the path pattern content, a character at a time, breaking it into path elements around separator boundaries and verifying the structure at each stage. Produces a PathPattern object that can be used for fast matching against paths. Each invocation of this method delegates to a new instance of theInternalPathPatternParser
because that class is not thread-safe.- 参数:
pathPattern
- the input path pattern, e.g. /project/{name}- 返回:
- a PathPattern for quickly matching paths against request paths
- 抛出:
PatternParseException
- in case of parse errors