类 RequestMethodsRequestCondition
- java.lang.Object
- org.springframework.web.servlet.mvc.condition.AbstractRequestCondition<RequestMethodsRequestCondition>
- org.springframework.web.servlet.mvc.condition.RequestMethodsRequestCondition
public final class RequestMethodsRequestCondition extends AbstractRequestCondition<RequestMethodsRequestCondition>
A logical disjunction (' || ') request condition that matches a request against a set ofRequestMethod
s.- 从以下版本开始:
- 3.1
- 作者:
- Arjen Poutsma, Rossen Stoyanchev
构造器概要
构造器 构造器 说明 RequestMethodsRequestCondition(RequestMethod... requestMethods)
Create a new instance with the given request methods.
方法概要
所有方法 实例方法 具体方法 修饰符和类型 方法 说明 RequestMethodsRequestCondition
combine(RequestMethodsRequestCondition other)
Returns a new instance with a union of the HTTP request methods from "this" and the "other" instance.int
compareTo(RequestMethodsRequestCondition other, HttpServletRequest request)
Returns: 0 if the two conditions contain the same number of HTTP request methods Less than 0 if "this" instance has an HTTP request method but "other" doesn't Greater than 0 "other" has an HTTP request method but "this" doesn'tprotected Collection<RequestMethod>
getContent()
Return the discrete items a request condition is composed of.RequestMethodsRequestCondition
getMatchingCondition(HttpServletRequest request)
Check if any of the HTTP request methods match the given request and return an instance that contains the matching HTTP request method only.Set<RequestMethod>
getMethods()
Returns allRequestMethod
s contained in this condition.protected String
getToStringInfix()
The notation to use when printing discrete items of content.从类继承的方法 org.springframework.web.servlet.mvc.condition.AbstractRequestCondition
equals, hashCode, isEmpty, toString
构造器详细资料
RequestMethodsRequestCondition
public RequestMethodsRequestCondition(RequestMethod... requestMethods)
Create a new instance with the given request methods.- 参数:
requestMethods
- 0 or more HTTP request methods; if, 0 the condition will match to every request
方法详细资料
getMethods
public Set<RequestMethod> getMethods()
Returns allRequestMethod
s contained in this condition.
getContent
protected Collection<RequestMethod> getContent()
从类复制的说明:AbstractRequestCondition
Return the discrete items a request condition is composed of.For example URL patterns, HTTP request methods, param expressions, etc.
- 指定者:
getContent
在类中AbstractRequestCondition<RequestMethodsRequestCondition>
- 返回:
- a collection of objects (never
null
)
getToStringInfix
protected String getToStringInfix()
从类复制的说明:AbstractRequestCondition
The notation to use when printing discrete items of content.For example
" || "
for URL patterns or" && "
for param expressions.
combine
public RequestMethodsRequestCondition combine(RequestMethodsRequestCondition other)
Returns a new instance with a union of the HTTP request methods from "this" and the "other" instance.- 参数:
other
- the condition to combine with.- 返回:
- a request condition instance that is the result of combining the two condition instances.
getMatchingCondition
public RequestMethodsRequestCondition getMatchingCondition(HttpServletRequest request)
Check if any of the HTTP request methods match the given request and return an instance that contains the matching HTTP request method only.- 参数:
request
- the current request- 返回:
- the same instance if the condition is empty (unless the request method is HTTP OPTIONS), a new condition with the matched request method, or
null
if there is no match or the condition is empty and the request method is OPTIONS.
compareTo
public int compareTo(RequestMethodsRequestCondition other, HttpServletRequest request)
Returns:- 0 if the two conditions contain the same number of HTTP request methods
- Less than 0 if "this" instance has an HTTP request method but "other" doesn't
- Greater than 0 "other" has an HTTP request method but "this" doesn't
It is assumed that both instances have been obtained via
getMatchingCondition(HttpServletRequest)
and therefore each instance contains the matching HTTP request method only or is otherwise empty.