问题
I have the following POJO:
@XmlRootElement(name="SessionStartInput")
public class SessionStartInput {
@XmlElement(name = "Header", required = true, nillable = true)
protected SessionStartInputHeader header;
@XmlElement(name = "Parameters", required = true, nillable = true)
protected SessionStartInputParameters parameters;
...
}
Which generates:
<SessionStartInput>
<Header></Header>
<Parameters></Parameters>
</SessionStartInput>
I want to generate:
<SessionStartInput>
<Input>
<Header></Header>
<Parameters></Parameters>
<Input>
</SessionStartInput>
Adding an additional Input wrapper, is there some sort XML annotation that can do this? I've checked @XmlElements
but this would mean altering the structure of the POJO. is there any workaround for this?
回答1:
Ended up changing the POJO to accommodate the change in xml data
来源:https://stackoverflow.com/questions/29469194/jaxb-add-additional-static-root-element