可以有两个具有相同名称的字段吗?
例如,假设我的对象是这样的:
@XmlRootElement(name = "test")
@XmlAccessorType(XmlAccessType.FIELD)
public class TestObject {
@XmlElement(name = "subObject", required = true)
private SubObject obj1;
@XmlElement(name = "subObject", required = true)
private SubObject obj2;
@XmlElement(name = "subObject1", required = true)
private SubObject obj3;
}
此处,仅渲染obj2
和obj3
,因为obj1
和obj2
具有相同的名称。
有没有办法强制MOXy渲染obj1
和obj2
甚至它们具有相同的名称?