在 JAXB 中解组后如何检查元素的存在?

How to check presence of element after unmarshalling in JAXB?

有人可以帮助我了解如何在将 XML 解组为对象后检查元素是否存在吗?元素没有属性,也是自闭的!我确实发现了几个与此相关的问题,但它没有任何具体的答案。

<Success /> //This is the self closing tag.

public class ParentClass {

    @XmlElement
    private Success success;

    public static class Success {

    }
}

此问题现已解决。我从 XML 消息中删除了 xmlns 属性。现在,如果存在 success 属性,我会在对象中获取它,否则它会显示为 null。