XML报文拼接 乱码

以下直接上源码:

/*Element root = doc.getRootElement();
        Element ACCOUNTLISTElement = new Element("ACCOUNTLIST");
        Element ACCOUNTElement = new Element("ACCOUNT");

        String mobile = autoRegistVo.getMOBILE();

        Element ACCOUNTNAMEElement = new Element("ACCOUNTNAME");
        ACCOUNTNAMEElement.addContent(mobile);
        ACCOUNTElement.addContent(ACCOUNTNAMEElement);

        Element ACCOUNTPWDElement = new Element("ACCOUNTPWD");
//        ACCOUNTPWDElement.addContent(" ");
        ACCOUNTElement.addContent(ACCOUNTPWDElement);

        Element ACCOUNTTYPEElement = new Element("ACCOUNTTYPE");
//        ACCOUNTTYPEElement.addContent(" ");
        ACCOUNTElement.addContent(ACCOUNTTYPEElement);

        Element AGENTIDElement = new Element("AGENTID");
        OfficeAccountEntity officeAccount = super.findOfficeAccount(mobile);
        if (officeAccount != null) {
            AGENTIDElement.addContent(officeAccount.getOfficeId());
        }
        ACCOUNTElement.addContent(AGENTIDElement);

        Element ISAUTOREGISTElement = new Element("ISAUTOREGIST");
//        ISAUTOREGISTElement.addContent(" ");
        ACCOUNTElement.addContent(ISAUTOREGISTElement);

        Element FIRSTLOGINTIMEElement = new Element("FIRSTLOGINTIME");
//        FIRSTLOGINTIMEElement.addContent(" ");
        ACCOUNTElement.addContent(FIRSTLOGINTIMEElement);

        Element FIRSTLOGINTYPEElement = new Element("FIRSTLOGINTYPE");
//        FIRSTLOGINTYPEElement.addContent("");
        ACCOUNTElement.addContent(FIRSTLOGINTYPEElement);

        Element ISBINDPOLICYElement = new Element("ISBINDPOLICY");
//        ISBINDPOLICYElement.addContent(" ");
        ACCOUNTElement.addContent(ISBINDPOLICYElement);

        ACCOUNTLISTElement.addContent(ACCOUNTElement);
        root.addContent(ACCOUNTLISTElement);

        String xmlStr = "";
        try {
            org.jdom2.output.Format format = org.jdom2.output.Format.getCompactFormat();
            format.setEncoding("UTF-8");// 设置xml文件的字符为UTF-8,解决中文问题

            XMLOutputter xmlout = new XMLOutputter(format);

            ByteArrayOutputStream bo = new ByteArrayOutputStream();
            xmlout.output(doc, bo);
            xmlStr = new String(bo.getByteArray(),"UTF-8")
       //xmlStr = bo.toString(); } catch (Exception e) { logger.error("补充认证中心xml结果失败"); } return xmlStr;
*/ //return JsonUtils.transferToJson(convertRegistFileToXml(registAccountExeitModel));

 

转载于:https://www.cnblogs.com/otways/p/11158753.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值