类 SimpleMessageConverter
- java.lang.Object
- org.springframework.messaging.converter.SimpleMessageConverter
- 所有已实现的接口:
MessageConverter
- 直接已知子类:
GenericMessageConverter
public class SimpleMessageConverter extends Object implements MessageConverter
A simple converter that simply unwraps the message payload as long as it matches the expected target class. Or reversely, simply wraps the payload in a message.Note that this converter ignores any content type information that may be present in message headers and should not be used if payload conversion is actually required.
- 从以下版本开始:
- 4.0
- 作者:
- Rossen Stoyanchev
构造器概要
构造器 构造器 说明 SimpleMessageConverter()
方法概要
所有方法 实例方法 具体方法 修饰符和类型 方法 说明 ObjectfromMessage(Message<?> message, Class<?> targetClass)Convert the payload of aMessagefrom a serialized form to a typed Object of the specified target class.Message<?>toMessage(Object payload, MessageHeaders headers)Create aMessagewhose payload is the result of converting the given payload Object to serialized form.
构造器详细资料
SimpleMessageConverter
public SimpleMessageConverter()
方法详细资料
fromMessage
public Object fromMessage(Message<?> message, Class<?> targetClass)
从接口复制的说明:MessageConverterConvert the payload of aMessagefrom a serialized form to a typed Object of the specified target class. TheMessageHeaders.CONTENT_TYPEheader 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- 参数:
message- the input messagetargetClass- the target class for the conversion- 返回:
- the result of the conversion, or
nullif the converter cannot perform the conversion
toMessage
public Message<?> toMessage(Object payload, MessageHeaders headers)
从接口复制的说明:MessageConverterCreate aMessagewhose payload is the result of converting the given payload Object to serialized form. The optionalMessageHeadersparameter may contain aMessageHeaders.CONTENT_TYPEheader to specify the target me