Class RegexRequestMatcher
java.lang.Object
org.springframework.security.web.util.matcher.RegexRequestMatcher
- All Implemented Interfaces:
- RequestMatcher
Uses a regular expression to decide whether a supplied the URL of a supplied
 
HttpServletRequest.
 Can also be configured to match a specific HTTP method.
 The match is performed against the servletPath + pathInfo + queryString of the
 request and is case-sensitive by default. Case-insensitive matching can be used by
 using the constructor which takes the caseInsensitive argument.- Since:
- 3.1
- 
Nested Class SummaryNested classes/interfaces inherited from interface org.springframework.security.web.util.matcher.RequestMatcherRequestMatcher.MatchResult
- 
Constructor SummaryConstructorsConstructorDescriptionRegexRequestMatcher(String pattern, String httpMethod) Creates a case-sensitivePatterninstance to match against the request.RegexRequestMatcher(String pattern, String httpMethod, boolean caseInsensitive) As above, but allows setting of whether case-insensitive matching should be used.
- 
Method SummaryModifier and TypeMethodDescriptionbooleanmatches(jakarta.servlet.http.HttpServletRequest request) Performs the match of the request URL (servletPath + pathInfo + queryString) against the compiled pattern.static RegexRequestMatcherregexMatcher(String pattern) Creates a case-sensitivePatterninstance to match against the request.static RegexRequestMatcherregexMatcher(org.springframework.http.HttpMethod method) Creates an instance that matches to all requests with the sameHttpMethod.static RegexRequestMatcherregexMatcher(org.springframework.http.HttpMethod method, String pattern) Creates a case-sensitivePatterninstance to match against the request.toString()Methods inherited from class java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.springframework.security.web.util.matcher.RequestMatchermatcher
- 
Constructor Details- 
RegexRequestMatcherCreates a case-sensitivePatterninstance to match against the request.- Parameters:
- pattern- the regular expression to compile into a pattern.
- httpMethod- the HTTP method to match. May be null to match all methods.
 
- 
RegexRequestMatcherAs above, but allows setting of whether case-insensitive matching should be used.- Parameters:
- pattern- the regular expression to compile into a pattern.
- httpMethod- the HTTP method to match. May be null to match all methods.
- caseInsensitive- if true, the pattern will be compiled with the- Pattern.CASE_INSENSITIVEflag set.
 
 
- 
- 
Method Details- 
regexMatcherCreates a case-sensitivePatterninstance to match against the request.- Parameters:
- pattern- the regular expression to compile into a pattern.
- Since:
- 5.8
 
- 
regexMatcherCreates an instance that matches to all requests with the sameHttpMethod.- Parameters:
- method- the HTTP method to match. Must not be null.
- Since:
- 5.8
 
- 
regexMatcherpublic static RegexRequestMatcher regexMatcher(org.springframework.http.HttpMethod method, String pattern) Creates a case-sensitivePatterninstance to match against the request.- Parameters:
- method- the HTTP method to match. May be null to match all methods.
- pattern- the regular expression to compile into a pattern.
- Since:
- 5.8
 
- 
matchespublic boolean matches(jakarta.servlet.http.HttpServletRequest request) Performs the match of the request URL (servletPath + pathInfo + queryString) against the compiled pattern. If the query string is present, a question mark will be prepended.- Specified by:
- matchesin interface- RequestMatcher
- Parameters:
- request- the request to match
- Returns:
- true if the pattern matches the URL, false otherwise.
 
- 
toString
 
-