public class PathPattern extends ObjectSE implements ComparableSE<PathPattern>
PathPattern
は、次のルールを使用して URL パスを照合します。
?
は 1 文字に一致します *
は、パスセグメント内の 0 個以上の文字に一致します **
は、パスの終わりまでゼロ個以上のパスセグメントと一致します {spring}
はパスセグメントと一致し、"spring" という名前の変数としてキャプチャーします {spring:[a-z]+}
は、"spring" という名前のパス変数として正規表現 [a-z]+
と一致します。{*spring}
は、パスの終わりまでゼロ個以上のパスセグメントと一致し、"spring" という名前の変数としてキャプチャーします /pages/t?st.html
— /pages/test.html
に一致しますが、/pages/tast.html
にも一致しますが、/pages/toast.html
には一致しません /resources/*.png
— resources
ディレクトリ内のすべての .png
ファイルに一致します /resources/**
— /resources/image.png
および /resources/css/spring.css
を含む、/resources/
パスにあるすべてのファイルに一致します /resources/{*path}
— /resources/
パスにあるすべてのファイルに一致し、それらの相対パスを "path" という名前の変数にキャプチャーします。/resources/image.png
は "Spring" -> "/image.png" と一致し、/resources/css/spring.css
は "Spring" -> "/css/spring.css" と一致します /resources/{filename:\\w+}.dat
は /resources/spring.dat
と一致し、値 "spring"
を filename
変数に割り当てます PathContainer
修飾子と型 | クラスと説明 |
---|---|
static class | PathPattern.PathMatchInfo 指定された一致パスのパターンに基づいて抽出された URI 変数およびパスパラメーター(マトリックス変数)のホルダー。 |
static class | PathPattern.PathRemainingMatchInfo パターンの開始での一致の結果のホルダー。 |
修飾子と型 | フィールドと説明 |
---|---|
static ComparatorSE<PathPattern> | SPECIFICITY_COMPARATOR パターンを次のように特異性でソートするコンパレータ: null インスタンスは最後です。 |
修飾子と型 | メソッドと説明 |
---|---|
PathPattern | combine(PathPattern pattern2string) このパターンを別のパターンと組み合わせます。 |
int | compareTo(PathPattern otherPattern) このパターンを提供されたパターンと比較します。このパターンがより具体的である場合、-1、0、+ 1 を返します。これは、提供されたパターンと同じか、より具体的ではありません。 |
boolean | equals(ObjectSE other) |
PathContainer | extractPathWithinPattern(PathContainer path) 指定されたパスのパターンマッピングされた部分を決定します。 |
StringSE | getPatternString() この PathPattern を作成するために解析された元の文字列を返します。 |
int | hashCode() |
PathPattern.PathMatchInfo | matchAndExtract(PathContainer pathContainer) このパターンを指定された URI パスに一致させ、抽出された URI テンプレート変数とパスパラメーター(マトリックス変数)を返します。 |
boolean | matches(PathContainer pathContainer) このパターンが指定されたパスに一致するかどうか。 |
PathPattern.PathRemainingMatchInfo | matchStartOfPath(PathContainer pathContainer) 指定されたパスの先頭に一致し、このパターンでカバーされていない残りの部分を返します。 |
StringSE | toString() |
cloneSE, finalizeSE, getClassSE, notifySE, notifyAllSE, waitSE, waitSE, waitSE
public static final ComparatorSE<PathPattern> SPECIFICITY_COMPARATOR
public StringSE getPatternString()
public boolean matches(PathContainer pathContainer)
pathContainer
- 照合を試みる候補パス true
@Nullable public PathPattern.PathMatchInfo matchAndExtract(PathContainer pathContainer)
pathContainer
- 照合を試みる候補パス null
@Nullable public PathPattern.PathRemainingMatchInfo matchStartOfPath(PathContainer pathContainer)
pathContainer
- 照合を試みる候補パス null
public PathContainer extractPathWithinPattern(PathContainer path)
例:
/docs/cvs/commit.html
' および '/docs/cvs/commit.html
->' '/docs/*
' および '/docs/cvs/commit
'-> 'cvs/commit
'/docs/cvs/*.html
' および '/docs/cvs/commit.html
->'commit.html
'/docs/**
' および '/docs/cvs/commit
->'cvs/commit
' 注 :matches(org.springframework.http.server.PathContainer)
が同じパスに対して true
を返すと想定していますが、これを強制していません。
path
- このパターンに一致するパス public int compareTo(@Nullable PathPattern otherPattern)
ComparableSE<PathPattern>
の compareToSE
public PathPattern combine(PathPattern pattern2string)
public int hashCode()
ObjectSE
の hashCodeSE
public StringSE toString()
ObjectSE
の toStringSE