java替换XML元素为空,java-如何使用JAXB为XML中的空元素生成结束标...

我正在使用JAXB生成XML.但是JAXB会生成一个空的Tag来自我关闭.但是我的客户想要单独的空标签.我知道两者都是平等的,但他不同意我的看法.请任何人提出解决方案.谢谢.

样例代码:

@XmlAccessorType(XmlAccessType.FIELD)

@XmlType(name = "", propOrder = {

"currencyCode",

"discountValue",

"setPrice",

"spendLowerThreshold",

"spendUpperThreshold",

"discountApportionmentPercent",

"discountApportionmentValue"

})

@XmlRootElement(name = "countryData")

public class CountryData {

protected String currencyCode;

protected String discountValue = "";

protected String setPrice = "";

protected String spendLowerThreshold = "";

protected String spendUpperThreshold = "";

protected String discountApportionmentPercent = "";

protected String discountApportionmentValue = "";

// Setters and Gettres

}

实际输出:

GBP

0.0

预期产量:

GBP

0.0

编组代码:

try {

Marshaller marshaller = JAXBContext.newInstance(CountryData.class).createMarshaller();

ByteArrayOutputStream os = new ByteArrayOutputStream();

marshaller.marshal(countryData , os);

log.debug("The PPV request raw XML -> " + os.toString());

} catch (JAXBException e) {

// nothing to do

}

我正在使用JDK 6.0

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值