0
我已經跨越了新的問題來了,我JAXB解組JAXB解組不是解組嵌套列表
鑑於此字符串作爲輸入
<ruleGroup id="1602" name="TestObject">
<simple column="simple" type="value" operator="equals" value="1" not="true"/>
</ruleGroup>
類不解析嵌套列表元素,只有正常的屬性(表示爲JSON):
{"id":1602,"name":"TestObject"}
這裏有什麼問題?我的類別是:
@XmlRootElement(name = "ruleGroup")
public class RuleGroup {
@XmlAttribute(name = "id")
public Long id;
@XmlAttribute(name = "name")
public String name;
@XmlElement(name = "simple")
public List<SimpleXML> simple;
}
和
public class SimpleXML {
@XmlAttribute(name = "column")
public String column = null;
@XmlAttribute(name = "type")
public String type = null;
@XmlAttribute(name = "operator")
public String operator = null;
@XmlAttribute(name = "value")
public String value = null;
@XmlAttribute(name = "not")
}
我解組非常標準:
RuleGroup rule;
JAXBContext jaxbContext = JAXBContext.newInstance(RuleGroup.class);
Unmarshaller jaxbUnmarshaller = jaxbContext.createUnmarshaller();
StringReader reader = new StringReader(test);
JAXBElement<RuleGroup> root = jaxbUnmarshaller.unmarshal(new StreamSource(reader), RuleGroup.class);
rule = (RuleGroup) root.getValue();
所以我不知道這個問題可能是什麼。關於我在做什麼的任何想法都是錯誤的?