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
精彩评论