Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
sesemomo
spring-framework
提交
f490f3ca
S
spring-framework
项目概览
sesemomo
/
spring-framework
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
S
spring-framework
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
f490f3ca
编写于
3月 13, 2017
作者:
R
Rossen Stoyanchev
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Polish SyncHandlerMethodArgumentResolver hiearchy
上级
dda8beeb
变更
12
隐藏空白更改
内联
并排
Showing
12 changed file
with
118 addition
and
84 deletion
+118
-84
spring-webflux/src/main/java/org/springframework/web/reactive/result/method/HandlerMethodArgumentResolver.java
...reactive/result/method/HandlerMethodArgumentResolver.java
+8
-5
spring-webflux/src/main/java/org/springframework/web/reactive/result/method/InvocableHandlerMethod.java
...rk/web/reactive/result/method/InvocableHandlerMethod.java
+14
-1
spring-webflux/src/main/java/org/springframework/web/reactive/result/method/SyncHandlerMethodArgumentResolver.java
...tive/result/method/SyncHandlerMethodArgumentResolver.java
+10
-5
spring-webflux/src/main/java/org/springframework/web/reactive/result/method/SyncInvocableHandlerMethod.java
...eb/reactive/result/method/SyncInvocableHandlerMethod.java
+13
-8
spring-webflux/src/main/java/org/springframework/web/reactive/result/method/annotation/AbstractNamedValueArgumentResolver.java
...method/annotation/AbstractNamedValueArgumentResolver.java
+6
-0
spring-webflux/src/main/java/org/springframework/web/reactive/result/method/annotation/AbstractNamedValueSyncArgumentResolver.java
...od/annotation/AbstractNamedValueSyncArgumentResolver.java
+25
-15
spring-webflux/src/main/java/org/springframework/web/reactive/result/method/annotation/InitBinderBindingContext.java
...ve/result/method/annotation/InitBinderBindingContext.java
+11
-11
spring-webflux/src/main/java/org/springframework/web/reactive/result/method/annotation/ModelArgumentResolver.java
...ctive/result/method/annotation/ModelArgumentResolver.java
+4
-3
spring-webflux/src/main/java/org/springframework/web/reactive/result/method/annotation/PathVariableMapMethodArgumentResolver.java
...hod/annotation/PathVariableMapMethodArgumentResolver.java
+3
-5
spring-webflux/src/main/java/org/springframework/web/reactive/result/method/annotation/RequestHeaderMapMethodArgumentResolver.java
...od/annotation/RequestHeaderMapMethodArgumentResolver.java
+7
-9
spring-webflux/src/main/java/org/springframework/web/reactive/result/method/annotation/RequestParamMapMethodArgumentResolver.java
...hod/annotation/RequestParamMapMethodArgumentResolver.java
+11
-17
spring-webflux/src/main/java/org/springframework/web/reactive/result/method/annotation/ServerWebExchangeArgumentResolver.java
.../method/annotation/ServerWebExchangeArgumentResolver.java
+6
-5
未找到文件。
spring-webflux/src/main/java/org/springframework/web/reactive/result/method/HandlerMethodArgumentResolver.java
浏览文件 @
f490f3ca
...
...
@@ -23,23 +23,26 @@ import org.springframework.web.reactive.BindingContext;
import
org.springframework.web.server.ServerWebExchange
;
/**
* Strategy
interface for resolving method parameters into argument values in
*
the context of a given
request.
* Strategy
to resolve the argument value for a method parameter in the context
*
of the current HTTP
request.
*
* @author Rossen Stoyanchev
* @since 5.0
*/
public
interface
HandlerMethodArgumentResolver
{
/**
* Whether this resolver supports the given method parameter.
* @param parameter the method parameter
*/
boolean
supportsParameter
(
MethodParameter
parameter
);
/**
* The returned {@link Mono} may produce one or zero values if the argument
* does not resolve to any value, which will result in {@code null} passed
* as the argument value.
* Resolve the value for the method parameter.
* @param parameter the method parameter
* @param bindingContext the binding context to use
* @param exchange the current exchange
* @return {@code Mono} for the argument value, possibly empty
*/
Mono
<
Object
>
resolveArgument
(
MethodParameter
parameter
,
BindingContext
bindingContext
,
ServerWebExchange
exchange
);
...
...
spring-webflux/src/main/java/org/springframework/web/reactive/result/method/InvocableHandlerMethod.java
浏览文件 @
f490f3ca
...
...
@@ -29,7 +29,6 @@ import java.util.stream.Stream;
import
reactor.core.publisher.Mono
;
import
org.springframework.core.DefaultParameterNameDiscoverer
;
import
org.springframework.core.GenericTypeResolver
;
import
org.springframework.core.MethodParameter
;
import
org.springframework.core.ParameterNameDiscoverer
;
import
org.springframework.core.annotation.AnnotatedElementUtils
;
...
...
@@ -94,6 +93,13 @@ public class InvocableHandlerMethod extends HandlerMethod {
this
.
resolvers
.
addAll
(
resolvers
);
}
/**
* Return the conifgured argument resolvers.
*/
public
List
<
HandlerMethodArgumentResolver
>
getResolvers
()
{
return
this
.
resolvers
;
}
/**
* Set the ParameterNameDiscoverer for resolving parameter names when needed
* (e.g. default request attribute name).
...
...
@@ -103,6 +109,13 @@ public class InvocableHandlerMethod extends HandlerMethod {
this
.
parameterNameDiscoverer
=
nameDiscoverer
;
}
/**
* Return the configured parameter name discoverer.
*/
public
ParameterNameDiscoverer
getParameterNameDiscoverer
()
{
return
this
.
parameterNameDiscoverer
;
}
/**
* Invoke the method for the given exchange.
...
...
spring-webflux/src/main/java/org/springframework/web/reactive/result/method/SyncHandlerMethodArgumentResolver.java
浏览文件 @
f490f3ca
...
...
@@ -33,20 +33,25 @@ import org.springframework.web.server.ServerWebExchange;
*/
public
interface
SyncHandlerMethodArgumentResolver
extends
HandlerMethodArgumentResolver
{
/**
* {@inheritDoc}
* <p>By default this simply delegates to {@link #resolveArgumentValue} for
* synchronous resolution.
*/
@Override
default
Mono
<
Object
>
resolveArgument
(
MethodParameter
parameter
,
BindingContext
c
ontext
,
default
Mono
<
Object
>
resolveArgument
(
MethodParameter
parameter
,
BindingContext
bindingC
ontext
,
ServerWebExchange
exchange
)
{
Optional
<
Object
>
value
=
resolveArgumentValue
(
parameter
,
context
,
exchange
);
return
Mono
.
justOrEmpty
(
value
);
return
Mono
.
justOrEmpty
(
resolveArgumentValue
(
parameter
,
bindingContext
,
exchange
));
}
/**
* Resolve the
method argument value synchronously returning an optional value
.
* Resolve the
value for the method parameter synchronously
.
* @param parameter the method parameter
* @param bindingContext the binding context to use
* @param exchange the current exchange
* @return
the resolved value if an
y
* @return
an {@code Optional} with the resolved value, possibly empt
y
*/
Optional
<
Object
>
resolveArgumentValue
(
MethodParameter
parameter
,
BindingContext
bindingContext
,
ServerWebExchange
exchange
);
...
...
spring-webflux/src/main/java/org/springframework/web/reactive/result/method/SyncInvocableHandlerMethod.java
浏览文件 @
f490f3ca
...
...
@@ -27,16 +27,17 @@ import org.springframework.web.reactive.HandlerResult;
import
org.springframework.web.server.ServerWebExchange
;
/**
*
An extension of {@code InvocableHandlerMethod} for synchronous, non-blocking
*
method invocation via {@link #invokeForHandlerResult}. By allowing only
* {@link
SyncHandlerMethodArgumentResolver}s to be configured, the invocation
*
is guaranteed to be non-blocking
.
*
Extension of {@code InvocableHandlerMethod} that can only be configured with
*
synchronous argument resolvers and thus exposing an additional, synchronous
* {@link
#invokeForHandlerResult} returning a {@code HandlerResult} vs
*
{@code Mono<HandlerResult>}
.
*
* @author Rossen Stoyanchev
* @since 5.0
*/
public
class
SyncInvocableHandlerMethod
extends
InvocableHandlerMethod
{
public
SyncInvocableHandlerMethod
(
HandlerMethod
handlerMethod
)
{
super
(
handlerMethod
);
}
...
...
@@ -53,12 +54,16 @@ public class SyncInvocableHandlerMethod extends InvocableHandlerMethod {
*/
@Override
public
void
setArgumentResolvers
(
List
<
HandlerMethodArgumentResolver
>
resolvers
)
{
resolvers
.
forEach
(
resolver
->
Assert
.
isInstanceOf
(
SyncHandlerMethodArgumentResolver
.
class
,
resolver
,
"SyncHandlerMethodArgumentResolver requires SyncHandlerMethodArgumentResolver"
));
resolvers
.
forEach
(
this
::
assertSyncResolvers
);
super
.
setArgumentResolvers
(
resolvers
);
}
private
void
assertSyncResolvers
(
HandlerMethodArgumentResolver
resolver
)
{
Assert
.
isInstanceOf
(
SyncHandlerMethodArgumentResolver
.
class
,
resolver
,
"SyncInvocableHandlerMethod requires resolvers of type "
+
"SyncHandlerMethodArgumentResolver"
);
}
/**
* Convenient alternative to {@link #setArgumentResolvers(List)} to configure
* synchronous argument resolvers.
...
...
@@ -75,7 +80,7 @@ public class SyncInvocableHandlerMethod extends InvocableHandlerMethod {
public
HandlerResult
invokeForHandlerResult
(
ServerWebExchange
exchange
,
BindingContext
bindingContext
,
Object
...
providedArgs
)
{
// This will not block
// This will not block
with only sync resolvers allowed
return
super
.
invoke
(
exchange
,
bindingContext
,
providedArgs
).
block
();
}
...
...
spring-webflux/src/main/java/org/springframework/web/reactive/result/method/annotation/AbstractNamedValueArgumentResolver.java
浏览文件 @
f490f3ca
...
...
@@ -171,6 +171,9 @@ public abstract class AbstractNamedValueArgumentResolver implements HandlerMetho
protected
abstract
Mono
<
Object
>
resolveName
(
String
name
,
MethodParameter
parameter
,
ServerWebExchange
exchange
);
/**
* Apply type conversion if necessary.
*/
private
Object
applyConversion
(
Object
value
,
NamedValueInfo
namedValueInfo
,
MethodParameter
parameter
,
BindingContext
bindingContext
,
ServerWebExchange
exchange
)
{
...
...
@@ -187,6 +190,9 @@ public abstract class AbstractNamedValueArgumentResolver implements HandlerMetho
return
value
;
}
/**
* Resolve the default value, if any.
*/
private
Mono
<
Object
>
getDefaultValue
(
NamedValueInfo
namedValueInfo
,
MethodParameter
parameter
,
BindingContext
bindingContext
,
Model
model
,
ServerWebExchange
exchange
)
{
...
...
spring-webflux/src/main/java/org/springframework/web/reactive/result/method/annotation/AbstractNamedValueSyncArgumentResolver.java
浏览文件 @
f490f3ca
...
...
@@ -38,35 +38,45 @@ import org.springframework.web.server.ServerWebExchange;
public
abstract
class
AbstractNamedValueSyncArgumentResolver
extends
AbstractNamedValueArgumentResolver
implements
SyncHandlerMethodArgumentResolver
{
public
AbstractNamedValueSyncArgumentResolver
(
ConfigurableBeanFactory
beanFactory
)
{
protected
AbstractNamedValueSyncArgumentResolver
(
ConfigurableBeanFactory
beanFactory
)
{
super
(
beanFactory
);
}
@Override
public
Mono
<
Object
>
resolveArgument
(
MethodParameter
parameter
,
BindingContext
bindingContext
,
ServerWebExchange
exchange
)
{
// Flip the default implementation from SyncHandlerMethodArgumentResolver:
// instead of delegating to (sync) resolveArgumentValue,
// call (async) super.resolveArgument shared with non-blocking resolvers;
// actual resolution below still sync...
return
super
.
resolveArgument
(
parameter
,
bindingContext
,
exchange
);
}
@Override
public
Optional
<
Object
>
resolveArgumentValue
(
MethodParameter
parameter
,
BindingContext
bindingContext
,
ServerWebExchange
exchange
)
{
BindingContext
context
,
ServerWebExchange
exchange
)
{
// This won't block since resolveName below doesn't
Object
value
=
resolveArgument
(
parameter
,
context
,
exchange
).
block
();
// This will not block
Object
value
=
resolveArgument
(
parameter
,
bindingContext
,
exchange
).
block
();
return
Optional
.
ofNullable
(
value
);
}
@Override
protected
Mono
<
Object
>
resolveName
(
String
name
,
MethodParameter
parameter
,
ServerWebExchange
exchange
)
{
return
Mono
.
justOrEmpty
(
resolveNamedValue
(
name
,
parameter
,
exchange
));
protected
final
Mono
<
Object
>
resolveName
(
String
name
,
MethodParameter
param
,
ServerWebExchange
exchange
)
{
return
Mono
.
justOrEmpty
(
resolveNamedValue
(
name
,
param
,
exchange
));
}
/**
* An abstract method for synchronous resolution of method argument values
* that sub-classes must implement.
* @param name the name of the value being resolved
* @param parameter the method parameter to resolve to an argument value
* (pre-nested in case of a {@link java.util.Optional} declaration)
* @param exchange the current exchange
* @return the resolved argument value, if any
* Actually resolve the value synchronously.
*/
protected
abstract
Optional
<
Object
>
resolveNamedValue
(
String
name
,
MethodParameter
parameter
,
ServerWebExchange
exchange
);
protected
abstract
Optional
<
Object
>
resolveNamedValue
(
String
name
,
MethodParameter
param
,
ServerWebExchange
exchange
);
}
spring-webflux/src/main/java/org/springframework/web/reactive/result/method/annotation/InitBinderBindingContext.java
浏览文件 @
f490f3ca
...
...
@@ -29,8 +29,7 @@ import org.springframework.web.reactive.result.method.SyncInvocableHandlerMethod
import
org.springframework.web.server.ServerWebExchange
;
/**
* Variant of {@link BindingContext} that further initializes {@code DataBinder}
* instances through {@code @InitBinder} methods.
* Extends {@link BindingContext} with {@code @InitBinder} method initialization.
*
* @author Rossen Stoyanchev
* @since 5.0
...
...
@@ -43,7 +42,7 @@ class InitBinderBindingContext extends BindingContext {
private
final
BindingContext
binderMethodContext
;
public
InitBinderBindingContext
(
WebBindingInitializer
initializer
,
InitBinderBindingContext
(
WebBindingInitializer
initializer
,
List
<
SyncInvocableHandlerMethod
>
binderMethods
)
{
super
(
initializer
);
...
...
@@ -53,24 +52,25 @@ class InitBinderBindingContext extends BindingContext {
@Override
protected
WebExchangeDataBinder
initDataBinder
(
WebExchangeDataBinder
binder
,
ServerWebExchange
exchange
)
{
protected
WebExchangeDataBinder
initDataBinder
(
WebExchangeDataBinder
dataBinder
,
ServerWebExchange
exchange
)
{
this
.
binderMethods
.
stream
()
.
filter
(
binderMethod
->
{
InitBinder
annotation
=
binderMethod
.
getMethodAnnotation
(
InitBinder
.
class
);
Collection
<
String
>
names
=
Arrays
.
asList
(
annotation
.
value
());
return
(
names
.
size
()
==
0
||
names
.
contains
(
b
inder
.
getObjectName
()));
return
(
names
.
size
()
==
0
||
names
.
contains
(
dataB
inder
.
getObjectName
()));
})
.
forEach
(
method
->
invokeBinderMethod
(
b
inder
,
exchange
,
method
));
.
forEach
(
method
->
invokeBinderMethod
(
dataB
inder
,
exchange
,
method
));
return
b
inder
;
return
dataB
inder
;
}
private
void
invokeBinderMethod
(
WebExchangeDataBinder
binder
,
ServerWebExchange
exchange
,
SyncInvocableHandlerMethod
binderMethod
)
{
private
void
invokeBinderMethod
(
WebExchangeDataBinder
dataBinder
,
S
erverWebExchange
exchange
,
S
yncInvocableHandlerMethod
binderMethod
)
{
Optional
<
Object
>
returnValue
=
binderMethod
.
invokeForHandlerResult
(
exchange
,
this
.
binderMethodContext
,
b
inder
)
.
invokeForHandlerResult
(
exchange
,
this
.
binderMethodContext
,
dataB
inder
)
.
getReturnValue
();
if
(
returnValue
.
isPresent
())
{
...
...
@@ -78,7 +78,7 @@ class InitBinderBindingContext extends BindingContext {
"@InitBinder methods should return void: "
+
binderMethod
);
}
// Should not happen (no
argument resolvers)
...
// Should not happen (no
Model argument resolution)
...
if
(!
this
.
binderMethodContext
.
getModel
().
asMap
().
isEmpty
())
{
throw
new
IllegalStateException
(
...
...
spring-webflux/src/main/java/org/springframework/web/reactive/result/method/annotation/ModelArgumentResolver.java
浏览文件 @
f490f3ca
...
...
@@ -32,16 +32,17 @@ import org.springframework.web.server.ServerWebExchange;
*/
public
class
ModelArgumentResolver
implements
SyncHandlerMethodArgumentResolver
{
@Override
public
boolean
supportsParameter
(
MethodParameter
parameter
)
{
return
Model
.
class
.
isAssignableFrom
(
parameter
.
getParameterType
());
}
@Override
public
Optional
<
Object
>
resolveArgumentValue
(
MethodParameter
parameter
,
BindingContext
bindingContext
,
ServerWebExchange
exchange
)
{
public
Optional
<
Object
>
resolveArgumentValue
(
MethodParameter
methodParameter
,
BindingContext
context
,
ServerWebExchange
exchange
)
{
return
Optional
.
of
(
bindingC
ontext
.
getModel
());
return
Optional
.
of
(
c
ontext
.
getModel
());
}
}
spring-webflux/src/main/java/org/springframework/web/reactive/result/method/annotation/PathVariableMapMethodArgumentResolver.java
浏览文件 @
f490f3ca
...
...
@@ -40,6 +40,7 @@ import org.springframework.web.server.ServerWebExchange;
*/
public
class
PathVariableMapMethodArgumentResolver
implements
SyncHandlerMethodArgumentResolver
{
@Override
public
boolean
supportsParameter
(
MethodParameter
parameter
)
{
PathVariable
ann
=
parameter
.
getParameterAnnotation
(
PathVariable
.
class
);
...
...
@@ -47,12 +48,9 @@ public class PathVariableMapMethodArgumentResolver implements SyncHandlerMethodA
&&
!
StringUtils
.
hasText
(
ann
.
value
()));
}
/**
* Return a Map with all URI template variables or an empty map.
*/
@Override
public
Optional
<
Object
>
resolveArgumentValue
(
MethodParameter
parameter
,
BindingContext
bindingContext
,
ServerWebExchange
exchange
)
{
public
Optional
<
Object
>
resolveArgumentValue
(
MethodParameter
methodParameter
,
BindingContext
context
,
ServerWebExchange
exchange
)
{
String
name
=
HandlerMapping
.
URI_TEMPLATE_VARIABLES_ATTRIBUTE
;
Object
value
=
exchange
.
getAttribute
(
name
).
orElse
(
Collections
.
emptyMap
());
...
...
spring-webflux/src/main/java/org/springframework/web/reactive/result/method/annotation/RequestHeaderMapMethodArgumentResolver.java
浏览文件 @
f490f3ca
...
...
@@ -42,6 +42,7 @@ import org.springframework.web.server.ServerWebExchange;
*/
public
class
RequestHeaderMapMethodArgumentResolver
implements
SyncHandlerMethodArgumentResolver
{
@Override
public
boolean
supportsParameter
(
MethodParameter
parameter
)
{
return
(
parameter
.
hasParameterAnnotation
(
RequestHeader
.
class
)
&&
...
...
@@ -49,17 +50,14 @@ public class RequestHeaderMapMethodArgumentResolver implements SyncHandlerMethod
}
@Override
public
Optional
<
Object
>
resolveArgumentValue
(
MethodParameter
parameter
,
BindingContext
context
,
ServerWebExchange
exchange
)
{
public
Optional
<
Object
>
resolveArgumentValue
(
MethodParameter
methodParameter
,
BindingContext
context
,
ServerWebExchange
exchange
)
{
HttpHeaders
headers
=
exchange
.
getRequest
().
getHeaders
();
Object
value
=
(
isMultiValueMap
(
parameter
)
?
headers
:
headers
.
toSingleValueMap
());
return
Optional
.
of
(
value
);
}
Class
<?>
paramType
=
methodParameter
.
getParameterType
();
boolean
isMultiValueMap
=
MultiValueMap
.
class
.
isAssignableFrom
(
paramType
);
private
boolean
isMultiValueMap
(
MethodParameter
parameter
)
{
Class
<?>
paramType
=
parameter
.
getParameterType
();
return
MultiValueMap
.
class
.
isAssignableFrom
(
paramType
);
HttpHeaders
headers
=
exchange
.
getRequest
().
getHeaders
();
return
Optional
.
of
(
isMultiValueMap
?
headers
:
headers
.
toSingleValueMap
());
}
}
spring-webflux/src/main/java/org/springframework/web/reactive/result/method/annotation/RequestParamMapMethodArgumentResolver.java
浏览文件 @
f490f3ca
...
...
@@ -45,11 +45,12 @@ import org.springframework.web.server.ServerWebExchange;
*/
public
class
RequestParamMapMethodArgumentResolver
implements
SyncHandlerMethodArgumentResolver
{
@Override
public
boolean
supportsParameter
(
MethodParameter
parameter
)
{
RequestParam
requestParam
=
parameter
.
getParameterAnnotation
(
RequestParam
.
class
);
public
boolean
supportsParameter
(
MethodParameter
methodParam
)
{
RequestParam
requestParam
=
methodParam
.
getParameterAnnotation
(
RequestParam
.
class
);
if
(
requestParam
!=
null
)
{
if
(
Map
.
class
.
isAssignableFrom
(
parameter
.
getParameterType
()))
{
if
(
Map
.
class
.
isAssignableFrom
(
methodParam
.
getParameterType
()))
{
return
!
StringUtils
.
hasText
(
requestParam
.
name
());
}
}
...
...
@@ -57,23 +58,16 @@ public class RequestParamMapMethodArgumentResolver implements SyncHandlerMethodA
}
@Override
public
Optional
<
Object
>
resolveArgumentValue
(
MethodParameter
parameter
,
BindingContext
context
,
ServerWebExchange
exchange
)
{
public
Optional
<
Object
>
resolveArgumentValue
(
MethodParameter
methodParameter
,
BindingContext
context
,
ServerWebExchange
exchange
)
{
MultiValueMap
<
String
,
String
>
requestParams
=
getRequestParams
(
exchange
);
Object
value
=
(
isMultiValueMap
(
parameter
)
?
requestParams
:
requestParams
.
toSingleValueMap
());
return
Optional
.
of
(
value
);
}
Class
<?>
paramType
=
methodParameter
.
getParameterType
();
boolean
isMultiValueMap
=
MultiValueMap
.
class
.
isAssignableFrom
(
paramType
);
private
MultiValueMap
<
String
,
String
>
getRequestParams
(
ServerWebExchange
exchange
)
{
MultiValueMap
<
String
,
String
>
params
=
exchange
.
getRequestParams
().
subscribe
().
peek
();
Assert
.
notNull
(
params
,
"Expected form data (if any) to be parsed."
);
return
params
;
}
MultiValueMap
<
String
,
String
>
requestParams
=
exchange
.
getRequestParams
().
subscribe
().
peek
();
Assert
.
notNull
(
requestParams
,
"Expected form data (if any) to be parsed."
);
private
boolean
isMultiValueMap
(
MethodParameter
parameter
)
{
Class
<?>
paramType
=
parameter
.
getParameterType
();
return
MultiValueMap
.
class
.
isAssignableFrom
(
paramType
);
return
Optional
.
of
(
isMultiValueMap
?
requestParams
:
requestParams
.
toSingleValueMap
());
}
}
spring-webflux/src/main/java/org/springframework/web/reactive/result/method/annotation/ServerWebExchangeArgumentResolver.java
浏览文件 @
f490f3ca
...
...
@@ -45,6 +45,7 @@ import org.springframework.web.server.ServerWebExchange;
*/
public
class
ServerWebExchangeArgumentResolver
implements
SyncHandlerMethodArgumentResolver
{
@Override
public
boolean
supportsParameter
(
MethodParameter
parameter
)
{
Class
<?>
paramType
=
parameter
.
getParameterType
();
...
...
@@ -55,10 +56,10 @@ public class ServerWebExchangeArgumentResolver implements SyncHandlerMethodArgum
}
@Override
public
Optional
<
Object
>
resolveArgumentValue
(
MethodParameter
parameter
,
BindingContext
context
,
ServerWebExchange
exchange
)
{
public
Optional
<
Object
>
resolveArgumentValue
(
MethodParameter
methodParameter
,
BindingContext
context
,
ServerWebExchange
exchange
)
{
Class
<?>
paramType
=
p
arameter
.
getParameterType
();
Class
<?>
paramType
=
methodP
arameter
.
getParameterType
();
if
(
ServerWebExchange
.
class
.
isAssignableFrom
(
paramType
))
{
return
Optional
.
of
(
exchange
);
}
...
...
@@ -73,8 +74,8 @@ public class ServerWebExchangeArgumentResolver implements SyncHandlerMethodArgum
}
else
{
// should never happen...
throw
new
IllegalArgumentException
(
"Unknown parameter type: "
+
paramType
+
" in method: "
+
p
arameter
.
getMethod
());
throw
new
IllegalArgumentException
(
"Unknown parameter type: "
+
paramType
+
" in method: "
+
methodP
arameter
.
getMethod
());
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录