Class PathPatternRequestMatcher
java.lang.Object
org.springframework.security.web.servlet.util.matcher.PathPatternRequestMatcher
- All Implemented Interfaces:
 RequestMatcher
A 
RequestMatcher that uses PathPatterns 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 PathPatternRequestMatcher.Builder.basePath
 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 classA 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 TypeMethodDescriptionbooleaninthashCode()matcher(jakarta.servlet.http.HttpServletRequest request) Returns a MatchResult for this RequestMatcher.booleanmatches(jakarta.servlet.http.HttpServletRequest request) Decides whether the rule implemented by the strategy matches the supplied request.toString()UsePathPatternParser.defaultInstanceto parse path patterns.withPathPatternParser(org.springframework.web.util.pattern.PathPatternParser parser) Use thisPathPatternParserto parse path patterns. 
- 
Method Details
- 
withDefaults
UsePathPatternParser.defaultInstanceto parse path patterns.- Returns:
 - a 
PathPatternRequestMatcher.Builderthat treats URIs as relative to the context path, if any 
 - 
withPathPatternParser
public static PathPatternRequestMatcher.Builder withPathPatternParser(org.springframework.web.util.pattern.PathPatternParser parser) Use thisPathPatternParserto parse path patterns.- Parameters:
 parser- thePathPatternParserto use- Returns:
 - a 
PathPatternRequestMatcher.Builderthat 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:
 matchesin 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:
 matcherin interfaceRequestMatcher- Returns:
 - the MatchResult from comparing this RequestMatcher against the HttpServletRequest
 
 - 
equals
 - 
hashCode
public int hashCode() - 
toString
 
 -