Class PathPatternRequestMatcher
java.lang.Object
org.springframework.security.web.servlet.util.matcher.PathPatternRequestMatcher
- All Implemented Interfaces:
RequestMatcher
A
RequestMatcher
that uses PathPattern
s to match against each
HttpServletRequest
. The provided path should be relative to the context path
(that is, it should exclude any context path).
You can provide the servlet path in servletPath
and
reuse for multiple matchers.
Note that the HandlerMapping
that contains the
related URI patterns must be using PathPatternParser.defaultInstance
. If that
is not the case, use PathPatternParser
to parse your path and provide a
PathPattern
in the constructor.
- Since:
- 6.5
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final class
A builder for specifying various elements of a request for the purpose of creating aPathPatternRequestMatcher
.Nested classes/interfaces inherited from interface org.springframework.security.web.util.matcher.RequestMatcher
RequestMatcher.MatchResult
-
Method Summary
Modifier and TypeMethodDescriptionboolean
int
hashCode()
matcher
(jakarta.servlet.http.HttpServletRequest request) Returns a MatchResult for this RequestMatcher.boolean
matches
(jakarta.servlet.http.HttpServletRequest request) Decides whether the rule implemented by the strategy matches the supplied request.toString()
UsePathPatternParser.defaultInstance
to parse path patterns.withPathPatternParser
(org.springframework.web.util.pattern.PathPatternParser parser) Use thisPathPatternParser
to parse path patterns.
-
Method Details
-
withDefaults
UsePathPatternParser.defaultInstance
to parse path patterns.- Returns:
- a
PathPatternRequestMatcher.Builder
that treats URIs as relative to the context path, if any
-
withPathPatternParser
public static PathPatternRequestMatcher.Builder withPathPatternParser(org.springframework.web.util.pattern.PathPatternParser parser) Use thisPathPatternParser
to parse path patterns.- Parameters:
parser
- thePathPatternParser
to use- Returns:
- a
PathPatternRequestMatcher.Builder
that treats URIs as relative to the givenservletPath
-
matches
public boolean matches(jakarta.servlet.http.HttpServletRequest request) Decides whether the rule implemented by the strategy matches the supplied request.- Specified by:
matches
in interfaceRequestMatcher
- Parameters:
request
- the request to check for a match- Returns:
- true if the request matches, false otherwise
-
matcher
Returns a MatchResult for this RequestMatcher. The default implementation returnsCollections.emptyMap()
whenRequestMatcher.MatchResult.getVariables()
is invoked.- Specified by:
matcher
in interfaceRequestMatcher
- Returns:
- the MatchResult from comparing this RequestMatcher against the HttpServletRequest
-
equals
-
hashCode
public int hashCode() -
toString
-