jaxb - how to create XML from polymorphic classes
问题 I've just started using JAXB to make XML output from java objects. A polymorphism exists in my java classes, which seems to not working in JAXB. Below is the way how I tried to deal with it, but in the output I haven't expected field: fieldA or fieldB. @XmlRootElement(name = "root") public class Root { @XmlElement(name = "fieldInRoot") private String fieldInRoot; @XmlElement(name = "child") private BodyResponse child; // + getters and setters } public abstract class BodyResponse { }