类 HiddenHttpMethodFilter
- java.lang.Object
- org.springframework.web.filter.reactive.HiddenHttpMethodFilter
- 所有已实现的接口:
WebFilter
public class HiddenHttpMethodFilter extends Object implements WebFilter
ReactiveWebFilter
that converts posted method parameters into HTTP methods, retrievable viaHttpRequest.getMethod()
. Since browsers currently only support GET and POST, a common technique is to use a normal POST with an additional hidden form field (_method
) to pass the "real" HTTP method along. This filter reads that parameter and changes theHttpRequest.getMethod()
return value usingServerWebExchange.mutate()
.The name of the request parameter defaults to
_method
, but can be adapted via themethodParamName
property.- 从以下版本开始:
- 5.0
- 作者:
- Greg Turnquist, Rossen Stoyanchev
字段概要
字段 修饰符和类型 字段 说明 static String
DEFAULT_METHOD_PARAMETER_NAME
Default name of the form parameter with the HTTP method to use.
构造器概要
构造器 构造器 说明 HiddenHttpMethodFilter()
方法概要
所有方法 实例方法 具体方法 修饰符和类型 方法 说明 reactor.core.publisher.Mono<Void>
filter(ServerWebExchange exchange, WebFilterChain chain)
Transform an HTTP POST into another method based onmethodParamName
.void
setMethodParamName(String methodParamName)
Set the name of the form parameter with the HTTP method to use.
字段详细资料
DEFAULT_METHOD_PARAMETER_NAME
public static final String DEFAULT_METHOD_PARAMETER_NAME
Default name of the form parameter with the HTTP method to use.- 另请参阅:
- 常量字段值
构造器详细资料
HiddenHttpMethodFilter
public HiddenHttpMethodFilter()
方法详细资料
setMethodParamName
public void setMethodParamName(String methodParamName)
Set the name of the form parameter with the HTTP method to use.By default this is set to
"_method"
.
filter
public reactor.core.publisher.Mono<Void> filter(ServerWebExchange exchange, WebFilterChain chain)
Transform an HTTP POST into another method based onmethodParamName
.