开发者

Customising jaxb marshalling output

My class is like the following:

class Employee {
  private String Code;
      //getter and setter below
}

Using jaxb when I marshal I am getting these elements:

<employee><code>some value</code></employee>

But I want the output to be like:

<Employee><Code>some value</Code></Employee>

To get above output I changed my code to:

@XmlRootElement(name="Employee")
class Employee {
      @XmlElement(name = "Myname")
  private String Code;
      //getter and setter below
}

When I marshal I am getting output as:

<Employee><Code>some value</Code><code>some value</code开发者_运维知识库></Employee>

How can I avoid creating <code>some value</code>?


Put the

@XmlElement(name = "Code")

On the getter method

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜