public static String textMessageToXml(TextMessage textMessage){
XStream xStream = new XStream();
xStream.alias("xml",textMessage.getClass());
return xStream.toXML(textMessage);
}
调用时报错
public static void main(String args[]){
TextMessage s=new TextMessage();
s.setContent("woshineirong");
s.setMsgType("text");
s.setToUserName("xuzhongyao");
s.setFromUserName("sdnaisdasd");
s.setCreateTime(new Date().getTime());
String tem = textMessageToXml(s);
System.out.println(tem);
}
main方法正常运行