public class MvcRequestMatcher extends java.lang.Object implements RequestMatcher, RequestVariablesExtractor
RequestMatcher
that uses Spring MVC's HandlerMappingIntrospector
to
match the path and extract variables.
It is important to understand that Spring MVC's matching is relative to the servlet
path. This means if you have mapped any servlet to a path that starts with "/" and is
greater than one, you should also specify the setServletPath(String)
attribute
to differentiate mappings.
RequestMatcher.MatchResult
Constructor and Description |
---|
MvcRequestMatcher(org.springframework.web.servlet.handler.HandlerMappingIntrospector introspector,
java.lang.String pattern) |
Modifier and Type | Method and Description |
---|---|
java.util.Map<java.lang.String,java.lang.String> |
extractUriTemplateVariables(javax.servlet.http.HttpServletRequest request)
Deprecated.
|
protected java.lang.String |
getServletPath() |
RequestMatcher.MatchResult |
matcher(javax.servlet.http.HttpServletRequest request)
Returns a MatchResult for this RequestMatcher The default implementation returns
Collections.emptyMap() when RequestMatcher.MatchResult.getVariables() is invoked. |
boolean |
matches(javax.servlet.http.HttpServletRequest request)
Decides whether the rule implemented by the strategy matches the supplied request.
|
void |
setMethod(org.springframework.http.HttpMethod method) |
void |
setServletPath(java.lang.String servletPath)
The servlet path to match on.
|
java.lang.String |
toString() |
public MvcRequestMatcher(org.springframework.web.servlet.handler.HandlerMappingIntrospector introspector, java.lang.String pattern)
public boolean matches(javax.servlet.http.HttpServletRequest request)
RequestMatcher
matches
in interface RequestMatcher
request
- the request to check for a match@Deprecated public java.util.Map<java.lang.String,java.lang.String> extractUriTemplateVariables(javax.servlet.http.HttpServletRequest request)
RequestVariablesExtractor
extractUriTemplateVariables
in interface RequestVariablesExtractor
request
- the HttpServletRequest to obtain a URL to extract the variables frompublic RequestMatcher.MatchResult matcher(javax.servlet.http.HttpServletRequest request)
RequestMatcher
Collections.emptyMap()
when RequestMatcher.MatchResult.getVariables()
is invoked.matcher
in interface RequestMatcher
public void setMethod(org.springframework.http.HttpMethod method)
method
- the method to setpublic void setServletPath(java.lang.String servletPath)
servletPath
- the servletPath to setprotected final java.lang.String getServletPath()
public java.lang.String toString()
toString
in class java.lang.Object