类 AbstractMessageConverterMethodProcessor
java.lang.Object
cn.taketoday.web.bind.resolver.AbstractMessageConverterMethodArgumentResolver
cn.taketoday.web.bind.resolver.AbstractMessageConverterMethodProcessor
- 所有已实现的接口:
ParameterResolvingStrategy,ReturnValueHandler
public abstract class AbstractMessageConverterMethodProcessor
extends AbstractMessageConverterMethodArgumentResolver
implements ReturnValueHandler
Extends
AbstractMessageConverterMethodArgumentResolver with the ability to handle method
return values by writing to the response with HttpMessageConverters.
write ActionMappingAnnotationHandler return value
- 从以下版本开始:
- 4.0 2022/1/23 12:30
- 作者:
- Arjen Poutsma, Rossen Stoyanchev, Brian Clozel, Juergen Hoeller, Harry Yang
- 另请参阅:
-
嵌套类概要
嵌套类 -
字段概要
字段修饰符和类型字段说明private final ContentNegotiationManagerprivate static final cn.taketoday.logging.Loggerprivate static final Type从类继承的字段 cn.taketoday.web.bind.resolver.AbstractMessageConverterMethodArgumentResolver
messageConverters从接口继承的字段 cn.taketoday.web.ReturnValueHandler
NONE_RETURN_VALUE -
构造器概要
构造器限定符构造器说明protectedAbstractMessageConverterMethodProcessor(List<HttpMessageConverter<?>> converters) Constructor with list of converters only.protectedAbstractMessageConverterMethodProcessor(List<HttpMessageConverter<?>> converters, ContentNegotiationManager contentNegotiationManager) Constructor with list of converters and ContentNegotiationManager.protectedAbstractMessageConverterMethodProcessor(List<HttpMessageConverter<?>> converters, ContentNegotiationManager manager, List<Object> requestResponseBodyAdvice) Constructor with list of converters and ContentNegotiationManager as well as request/response body advice instances. -
方法概要
修饰符和类型方法说明private voidCheck if the path has a file extension and whether the extension is either on the list ofsafe extensionsor explicitlyregistered.private voiddetermineCompatibleMediaTypes(List<MediaType> acceptableTypes, List<MediaType> producibleTypes, List<MediaType> mediaTypesToUse) getAcceptableMediaTypes(RequestContext request) private TypegetGenericType(cn.taketoday.core.MethodParameter returnType) Return the generic type of thereturnType(or of the nested type if it is anHttpEntity).private MediaTypegetMostSpecificMediaType(MediaType acceptType, MediaType produceType) Return the more specific of the acceptable and the producible media types with the q-value of the former.getProducibleMediaTypes(RequestContext request, Class<?> valueClass) Returns the media types that can be produced.getProducibleMediaTypes(RequestContext request, Class<?> valueClass, Type targetType) Returns the media types that can be produced.protected Class<?>getReturnValueType(Object value, cn.taketoday.core.MethodParameter returnType) Return the type of the value to be written to the response.protected booleanisResourceType(Object value, cn.taketoday.core.MethodParameter returnType) Return whether the returned value or the declared return type extendsResource.private booleannotSafeExtension(RequestContext request, String extension) private MediaTyperesolveMediaType(RequestContext request, String extension) private booleansafeMediaType(MediaType mediaType) protected <T> voidwriteWithMessageConverters(T value, cn.taketoday.core.MethodParameter returnType, RequestContext context) Writes the given return type to the given output message.从类继承的方法 cn.taketoday.web.bind.resolver.AbstractMessageConverterMethodArgumentResolver
adaptArgumentIfNecessary, closeStreamIfNecessary, getAdvice, getSupportedMediaTypes, isBindExceptionRequired, readWithMessageConverters, readWithMessageConverters, validateIfApplicable, validateIfApplicable从类继承的方法 java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait从接口继承的方法 cn.taketoday.web.bind.resolver.ParameterResolvingStrategy
resolveArgument, supportsParameter从接口继承的方法 cn.taketoday.web.ReturnValueHandler
handleReturnValue, supportsHandler, supportsReturnValue
-
字段详细资料
-
log
private static final cn.taketoday.logging.Logger log -
SAFE_EXTENSIONS
-
SAFE_MEDIA_BASE_TYPES
-
ALL_APPLICATION_MEDIA_TYPES
-
RESOURCE_REGION_LIST_TYPE
-
contentNegotiationManager
-
problemMediaTypes
-
safeExtensions
-
-
构造器详细资料
-
AbstractMessageConverterMethodProcessor
Constructor with list of converters only. -
AbstractMessageConverterMethodProcessor
protected AbstractMessageConverterMethodProcessor(List<HttpMessageConverter<?>> converters, @Nullable ContentNegotiationManager contentNegotiationManager) Constructor with list of converters and ContentNegotiationManager. -
AbstractMessageConverterMethodProcessor
protected AbstractMessageConverterMethodProcessor(List<HttpMessageConverter<?>> converters, @Nullable ContentNegotiationManager manager, @Nullable List<Object> requestResponseBodyAdvice) Constructor with list of converters and ContentNegotiationManager as well as request/response body advice instances.
-
-
方法详细资料
-
writeWithMessageConverters
protected <T> void writeWithMessageConverters(@Nullable T value, @Nullable cn.taketoday.core.MethodParameter returnType, RequestContext context) throws IOException, HttpMediaTypeNotAcceptableException, HttpMessageNotWritableException Writes the given return type to the given output message.- 参数:
value- the value to write to the output messagereturnType- the type of the valuecontext- the output message to write to and Used to inspect theAcceptheader.- 抛出:
IOException- thrown in case of I/O errorsHttpMediaTypeNotAcceptableException- thrown when the conditions indicated by theAcceptheader on the request cannot be met by the message convertersHttpMessageNotWritableException- thrown if a given message cannot be written by a converter, or if the content-type chosen by the server has no compatible converter.
-
getReturnValueType
protected Class<?> getReturnValueType(@Nullable Object value, @Nullable cn.taketoday.core.MethodParameter returnType) Return the type of the value to be written to the response. Typically this is a simple check via getClass on the value but if the value is null, then the return type needs to be examined possibly including generic type determination (e.g.ResponseEntity<T>). -
isResourceType
protected boolean isResourceType(@Nullable Object value, @Nullable cn.taketoday.core.MethodParameter returnType) Return whether the returned value or the declared return type extendsResource. -
getGenericType
Return the generic type of thereturnType(or of the nested type if it is anHttpEntity). -
getProducibleMediaTypes
Returns the media types that can be produced. -
getProducibleMediaTypes
protected List<MediaType> getProducibleMediaTypes(RequestContext request, Class<?> valueClass, @Nullable Type targetType) Returns the media types that can be produced. The resulting media types are:- The producible media types specified in the request mappings, or
- Media types of configured converters that can write the specific return value, or
MediaType.ALL
-
getAcceptableMediaTypes
private List<MediaType> getAcceptableMediaTypes(RequestContext request) throws HttpMediaTypeNotAcceptableException -
determineCompatibleMediaTypes
-
getMostSpecificMediaType
Return the more specific of the acceptable and the producible media types with the q-value of the former. -
addContentDispositionHeader
Check if the path has a file extension and whether the extension is either on the list ofsafe extensionsor explicitlyregistered. If not, and the status is in the 2xx range, a 'Content-Disposition' header with a safe attachment file name ("f.txt") is added to prevent RFD exploits. -
notSafeExtension
-
resolveMediaType
-
safeMediaType
-