类 AbstractMessageConverterMethodArgumentResolver
java.lang.Object
cn.taketoday.web.bind.resolver.AbstractMessageConverterMethodArgumentResolver
- 所有已实现的接口:
ParameterResolvingStrategy
public abstract class AbstractMessageConverterMethodArgumentResolver
extends Object
implements ParameterResolvingStrategy
A base class for resolving method argument values by reading from the body of
a request with
HttpMessageConverters.- 从以下版本开始:
- 4.0 2022/1/22 19:40
- 作者:
- Arjen Poutsma, Rossen Stoyanchev, Juergen Hoeller, Harry Yang
-
嵌套类概要
嵌套类修饰符和类型类说明private static class -
字段概要
字段修饰符和类型字段说明private final RequestResponseBodyAdviceChainprivate static final cn.taketoday.logging.Loggerprotected final List<HttpMessageConverter<?>>private static final Objectprivate static final EnumSet<HttpMethod> -
构造器概要
构造器构造器说明AbstractMessageConverterMethodArgumentResolver(List<HttpMessageConverter<?>> converters) Basic constructor with converters only.AbstractMessageConverterMethodArgumentResolver(List<HttpMessageConverter<?>> converters, List<Object> requestResponseBodyAdvice) Constructor with converters andRequest~andResponseBodyAdvice. -
方法概要
修饰符和类型方法说明protected ObjectadaptArgumentIfNecessary(Object arg, cn.taketoday.core.MethodParameter parameter) Adapt the given argument against the method parameter, if necessary.(专用程序包) voidAllow for closing the body stream if necessary, e.g. for part streams in a multipart request.(专用程序包) RequestResponseBodyAdviceChainReturn the configuredRequestBodyAdviceandRequestBodyAdvicewhere each instance may be wrapped as aControllerAdviceBean.getSupportedMediaTypes(Class<?> clazz) Return the media types supported by all provided message converters sorted by specificity viaMimeTypeUtils.sortBySpecificity(List).protected booleanisBindExceptionRequired(WebDataBinder binder, cn.taketoday.core.MethodParameter parameter) Whether to raise a fatal bind exception on validation errors.protected <T> ObjectreadWithMessageConverters(HttpInputMessage inputMessage, cn.taketoday.core.MethodParameter parameter, Type targetType) Create the method argument value of the expected parameter type by reading from the given HttpInputMessage.protected ObjectreadWithMessageConverters(RequestContext request, cn.taketoday.core.MethodParameter parameter, Type paramType) Create the method argument value of the expected parameter type by reading from the given request.protected voidvalidateIfApplicable(WebDataBinder binder, cn.taketoday.core.MethodParameter parameter) Validate the binding target if applicable.protected voidvalidateIfApplicable(RequestContext context, cn.taketoday.core.MethodParameter parameter, Object arg) 从类继承的方法 java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait从接口继承的方法 cn.taketoday.web.bind.resolver.ParameterResolvingStrategy
resolveArgument, supportsParameter
-
字段详细资料
-
log
private static final cn.taketoday.logging.Logger log -
SUPPORTED_METHODS
-
NO_VALUE
-
messageConverters
-
advice
-
-
构造器详细资料
-
AbstractMessageConverterMethodArgumentResolver
Basic constructor with converters only. -
AbstractMessageConverterMethodArgumentResolver
public AbstractMessageConverterMethodArgumentResolver(List<HttpMessageConverter<?>> converters, @Nullable List<Object> requestResponseBodyAdvice) Constructor with converters andRequest~andResponseBodyAdvice.
-
-
方法详细资料
-
getAdvice
RequestResponseBodyAdviceChain getAdvice()Return the configuredRequestBodyAdviceandRequestBodyAdvicewhere each instance may be wrapped as aControllerAdviceBean. -
readWithMessageConverters
@Nullable protected Object readWithMessageConverters(RequestContext request, cn.taketoday.core.MethodParameter parameter, Type paramType) throws IOException, HttpMediaTypeNotSupportedException, HttpMessageNotReadableException Create the method argument value of the expected parameter type by reading from the given request.- 参数:
request- the current requestparameter- the method parameter descriptor (may benull)paramType- the type of the argument value to be created- 返回:
- the created method argument value
- 抛出:
IOException- if the reading from the request failsHttpMediaTypeNotSupportedException- if no suitable message converter is foundHttpMessageNotReadableException
-
readWithMessageConverters
@Nullable protected <T> Object readWithMessageConverters(HttpInputMessage inputMessage, cn.taketoday.core.MethodParameter parameter, Type targetType) throws IOException, HttpMediaTypeNotSupportedException, HttpMessageNotReadableException Create the method argument value of the expected parameter type by reading from the given HttpInputMessage.- 参数:
inputMessage- the HTTP input message representing the current requestparameter- the method parameter descriptortargetType- the target type, not necessarily the same as the method parameter type, e.g. forHttpEntity<String>.- 返回:
- the created method argument value
- 抛出:
IOException- if the reading from the request failsHttpMediaTypeNotSupportedException- if no suitable message converter is foundHttpMessageNotReadableException
-
validateIfApplicable
protected void validateIfApplicable(RequestContext context, cn.taketoday.core.MethodParameter parameter, Object arg) throws Throwable - 抛出:
Throwable
-
validateIfApplicable
protected void validateIfApplicable(WebDataBinder binder, cn.taketoday.core.MethodParameter parameter) Validate the binding target if applicable.The default implementation checks for
@jakarta.validation.Valid, InfraValidated, and custom annotations whose name starts with "Valid".- 参数:
binder- the DataBinder to be usedparameter- the method parameter descriptor- 另请参阅:
-
isBindExceptionRequired
protected boolean isBindExceptionRequired(WebDataBinder binder, cn.taketoday.core.MethodParameter parameter) Whether to raise a fatal bind exception on validation errors.- 参数:
binder- the data binder used to perform data bindingparameter- the method parameter descriptor- 返回:
trueif the next method argument is not of typeErrors
-
getSupportedMediaTypes
Return the media types supported by all provided message converters sorted by specificity viaMimeTypeUtils.sortBySpecificity(List). -
adaptArgumentIfNecessary
@Nullable protected Object adaptArgumentIfNecessary(@Nullable Object arg, cn.taketoday.core.MethodParameter parameter) Adapt the given argument against the method parameter, if necessary.- 参数:
arg- the resolved argumentparameter- the method parameter descriptor- 返回:
- the adapted argument, or the original resolved argument as-is
-
closeStreamIfNecessary
Allow for closing the body stream if necessary, e.g. for part streams in a multipart request.
-