类 GenericMessageConverter
- java.lang.Object
- org.springframework.messaging.converter.SimpleMessageConverter
- org.springframework.messaging.converter.GenericMessageConverter
- 所有已实现的接口:
MessageConverter
public class GenericMessageConverter extends SimpleMessageConverter
An extension of theSimpleMessageConverter
that uses aConversionService
to convert the payload of the message to the requested type.Return
null
if the conversion service cannot convert from the payload type to the requested type.- 从以下版本开始:
- 4.1
- 作者:
- Stephane Nicoll
- 另请参阅:
ConversionService
构造器概要
构造器 构造器 说明 GenericMessageConverter()
Create a new instance with a defaultConversionService
.GenericMessageConverter(ConversionService conversionService)
Create a new instance with the givenConversionService
.
方法概要
所有方法 实例方法 具体方法 修饰符和类型 方法 说明 Object
fromMessage(Message<?> message, Class<?> targetClass)
Convert the payload of aMessage
from a serialized form to a typed Object of the specified target class.从类继承的方法 org.springframework.messaging.converter.SimpleMessageConverter
toMessage
构造器详细资料
GenericMessageConverter
public GenericMessageConverter()
Create a new instance with a defaultConversionService
.
GenericMessageConverter
public GenericMessageConverter(ConversionService conversionService)
Create a new instance with the givenConversionService
.
方法详细资料
fromMessage
public Object fromMessage(Message<?> message, Class<?> targetClass)
从接口复制的说明:MessageConverter
Convert the payload of aMessage
from a serialized form to a typed Object of the specified target class. TheMessageHeaders.CONTENT_TYPE
header should indicate the MIME type to convert from.If the converter does not support the specified media type or cannot perform the conversion, it should return
null
.- 指定者:
fromMessage
在接口中MessageConverter
- 覆盖:
fromMessage
在类中SimpleMessageConverter
- 参数:
message
- the input messagetargetClass
- the target class for the conversion- 返回:
- the result of the conversion, or
null
if the converter cannot perform the conversion