package com.tarena.xmlbean.test.testbean; import javax.xml.bind.annotation.XmlAccessType; @XmlAccessorType(XmlAccessType.FIELD) public Billhead getBillhead() { public void setBillhead(Billhead billhead) { |
package com.tarena.xmlbean.test.testbean; import javax.xml.bind.annotation.XmlAccessType; @XmlAccessorType(XmlAccessType.FIELD) public String getCreater() { public void setCreater(String creater) { public String getPk_group() { public void setPk_group(String pk_group) { public String getPk_org() { public void setPk_org(String pk_org) { public String getOfficialprintuser() { public void setOfficialprintuser(String officialprintuser) { |
package com.tarena.xmlbean.test.testbean; import javax.xml.bind.annotation.*; import java.util.List; public String getAccount() { public void setAccount(String account) { public String getBilltype() { public void setBilltype(String billtype) { public String getBusinessunitcode() { public void setBusinessunitcode(String businessunitcode) { public String getFilename() { public void setFilename(String filename) { public String getGroupcode() { public void setGroupcode(String groupcode) { public String getIsexchang() { public void setIsexchang(String isexchang) { public String getReplace() { public void setReplace(String replace) { public String getRoottag() { public void setRoottag(String roottag) { public String getSender() { public void setSender(String sender) { public List<Bill> getBillList() { public void setBillList(List<Bill> billList) { |
aatext.xml |
<?xml version='1.0' encoding='gb2312'?> <ufinterface account='develop' billtype='F0' businessunitcode='' filename='' groupcode='001' isexchange='Y' replace='Y' roottag='' sender='ERP'> <bill> <billhead> <creater>ERP</creater>//后补的 <pk_group>001</pk_group> <pk_org>0101</pk_org> <officialprintuser>ERP</officialprintuser> <officialprintdate>"+nowDate+"</officialprintdate> <pk_billtype>F0</pk_billtype> <pk_tradetype>F0-Cxx-02</pk_tradetype> <confirmuser>ERP</confirmuser> <src_syscode>17</src_syscode> <syscode>0</syscode> <billstatus>1</billstatus> // <billdate>2017-08-01 14:36:12</billdate> <billdate>"+nowDate+"</billdate>//起租日期odate=====================================================起租日期odate <billmaker>ERP</billmaker> <approver>ERP</approver> <approvedate>"+nowDate+"</approvedate> <rate>1</rate> <effectstatus>10</effectstatus> <pk_deptid>"+globalStartRentBean.getNcdeptno()+"</pk_deptid> <pk_psndoc>"+globalStartRentBean.getBcode()+"</pk_psndoc>//9项目经理 <customer>"+globalStartRentBean.getCcodetrust()+"</customer> <pk_currtype>CNY</pk_currtype> <objtype>0</objtype> <scomment>"+globalStartRentBean.getPcode()+"</scomment> <def2>"+globalStartRentBean.getInvcode()+"</def2>//6单据号 <def3>"+globalStartRentBean.getIndustry()+"</def3> <def7>"+globalStartRentBean.getPicode()+"</def7> <def8>"+globalStartRentBean.getPcode()+"</def8> <def9>"+globalStartRentBean.getLeas_type()+"</def9> <def4>"+globalStartRentBean.getChangesign()+"</def4> <bodys> <item> <customer>"+globalStartRentBean.getCcodetrust()+"</customer> <postunit> </postunit> <pausetransact>N</pausetransact> <pk_billtype>F0</pk_billtype> <billclass>ys</billclass> <pk_tradetype>F0-Cxx-02</pk_tradetype> <busidate>"+Odate+"</busidate> <objtype>0</objtype> <direction>1</direction> <buysellflag>1</buysellflag> <pk_currtype>CNY</pk_currtype> <rate>1</rate> <pk_deptid>111</pk_deptid> <pk_psndoc>"+globalStartRentBean.getBcode()+"</pk_psndoc>//9项目经理 <money_de>"+globalStartRentBean.getRmb()+"</money_de> <local_money_de>"+globalStartRentBean.getRmb()+"</local_money_de> <notax_de>"+globalStartRentBean.getRmb()+"</notax_de> <local_notax_de>"+globalStartRentBean.getRmb()+"</local_notax_de> <taxrate>"+(newRemark_2==null?"0.00":newRemark_2)+"</taxrate> <def16>"+(globalStartRentBean.getRemark_o().equals("营业税")?"1":"2")+"</def16> <def7>"+globalStartRentBean.getInvtype()+"</def7> <contractno>"+globalStartRentBean.getOrdcode()+"</contractno> <def18>"+(newRemark_2==null?"0.00":newRemark_2)+"</def18> <def19>"+(newRemark_2==null?"0.00":newRemark_2)+"</def19> </item> </bodys> </billhead> </bill> </ufinterface> |
@XmlAccessorType(XmlAccessType.FIELD) <ufinterface(元素) account='develop' billtype='F0' businessunitcode='' filename='' groupcode='001' isexchange='Y' replace='Y' roottag='' sender='ERP'></ufinterface> @XmlAttribute //属性指的节点中的一些属性 @XmlElement(name = "bill") //元素--指的xml节点(可以这样理解:元素是成对的,属性是单个的) |
package com.tarena.xmlbean.util; import javax.xml.bind.JAXBContext; public class JaxbUtil { public static String convertToXml(Object obj, String encoding) { public static <T> T converyToJavaBean(String xml, Class<T> c) { |