陈旭猴

博客园 首页 新随笔 联系 订阅 管理
 1     public void pushEmployee(EmpPushToTianFangRequest request){
 2         try {
 3             StringWriter sw = new StringWriter();
 4             JAXBContext context = JAXBContext.newInstance(EmpPushToTianFangRequest.class);
 5             Marshaller marshaller = context.createMarshaller();
 6             marshaller.marshal(request, sw);
 7             System.out.println(sw.toString());
 8         } catch (JAXBException e) {
 9             e.printStackTrace();
10         }
11     }
1
marshal方法在JDK中的声明:
 void javax.xml.bind.Marshaller.marshal(Object jaxbElement, Writer writer) throws JAXBException

使用
StringWriter   接受
Writer 



 

posted on 2016-12-24 10:55  陈旭猴  阅读(434)  评论(0编辑  收藏  举报