public final class AntPathRequestMatcher extends Object implements RequestMatcher, RequestVariablesExtractor
servletPath + pathInfo
) of an HttpServletRequest
. The query string of
the URL is ignored and matching is case-insensitive or case-sensitive depending on the
arguments passed into the constructor.
Using a pattern value of /**
or **
is treated as a universal match,
which will match any request. Patterns which end with /**
(and have no other
wildcards) are optimized by using a substring match — a pattern of
/aaa/**
will match /aaa
, /aaa/
and any sub-directories, such as
/aaa/bbb/ccc
.
For all other cases, Spring's AntPathMatcher
is used to perform the match. See
the Spring documentation for this class for comprehensive information on the syntax
used.
AntPathMatcher
Constructor and Description |
---|
AntPathRequestMatcher(String pattern)
Creates a matcher with the specific pattern which will match all HTTP methods in a
case insensitive manner.
|
AntPathRequestMatcher(String pattern,
String httpMethod)
Creates a matcher with the supplied pattern and HTTP method in a case insensitive
manner.
|
AntPathRequestMatcher(String pattern,
String httpMethod,
boolean caseSensitive)
Creates a matcher with the supplied pattern which will match the specified Http
method
|
AntPathRequestMatcher(String pattern,
String httpMethod,
boolean caseSensitive,
UrlPathHelper urlPathHelper)
Creates a matcher with the supplied pattern which will match the specified Http
method
|
Modifier and Type | Method and Description |
---|---|
boolean |
equals(Object obj) |
Map<String,String> |
extractUriTemplateVariables(javax.servlet.http.HttpServletRequest request)
Extract URL template variables from the request.
|
String |
getPattern() |
int |
hashCode() |
boolean |
matches(javax.servlet.http.HttpServletRequest request)
Returns true if the configured pattern (and HTTP-Method) match those of the
supplied request.
|
String |
toString() |
public AntPathRequestMatcher(String pattern)
pattern
- the ant pattern to use for matchingpublic AntPathRequestMatcher(String pattern, String httpMethod)
pattern
- the ant pattern to use for matchinghttpMethod
- the HTTP method. The matches
method will return false if
the incoming request doesn't have the same method.public AntPathRequestMatcher(String pattern, String httpMethod, boolean caseSensitive)
pattern
- the ant pattern to use for matchinghttpMethod
- the HTTP method. The matches
method will return false if
the incoming request doesn't doesn't have the same method.caseSensitive
- true if the matcher should consider case, else falsepublic AntPathRequestMatcher(String pattern, String httpMethod, boolean caseSensitive, UrlPathHelper urlPathHelper)
pattern
- the ant pattern to use for matchinghttpMethod
- the HTTP method. The matches
method will return false if
the incoming request doesn't doesn't have the same method.caseSensitive
- true if the matcher should consider case, else falseurlPathHelper
- if non-null, will be used for extracting the path from the HttpServletRequestpublic boolean matches(javax.servlet.http.HttpServletRequest request)
matches
in interface RequestMatcher
request
- the request to match against. The ant pattern will be matched
against the servletPath
+ pathInfo
of the request.public Map<String,String> extractUriTemplateVariables(javax.servlet.http.HttpServletRequest request)
RequestVariablesExtractor
extractUriTemplateVariables
in interface RequestVariablesExtractor
request
- the HttpServletRequest to obtain a URL to extract the variables frompublic String getPattern()