【发布时间】:2017-01-06 20:28:09
【问题描述】:
我无法解组我的数据。我收到以下错误:
错误 FsceClient - getDataInMatches 中的错误:意外元素 (uri:“”,本地:“SearchAndList”)。预期元素是(无) 要求的参数:+COUNTRY=US+YR=2016+DIV=Ford+WB=122.0 javax.xml.bind.UnmarshalException:意外元素(uri:“”,本地:“SearchAndList”)。预期元素是(无) 在 com.sun.xml.internal.bind.v2.runtime.unmarshaller.UnmarshallingContext.handleEvent(UnmarshallingContext.java:726)
这是我的 xml 文件:
<SearchAndList>
<fvd>
+COUNTRY=US+YR=2016+DIV=Ford+WB=122.0
</fvd>
<sol>
<rsi>
<sType>Ss</sType>
<mHave>true</mHave>
<toAr>0</toAr>
<toAr>0</toAr>
<toAr>22</toAr>
</rsi>
<rsi>
<sType>ssa</sType>
<mHave>true</mHave>
<toAr>77</toAr>
</rsi>
</sol>
<sol>
<rsi>
<sType>sve</sType>
<mHave>false</mHave>
<toAr>0</toAr>
<toAr>21</toAr>
</rsi>
</sol>
</SearchAndList>
【问题讨论】:
-
请编辑您的问题并显示您的 XML 架构以及 XML。如果我们能看到进行解组的代码也会有所帮助。
-
我对网络服务很陌生。我正在使用注释:这是我的代码: UnmarshallerPool searchAndListPool = null; JAXBContext jaxbContext_SearchAndList = JAXBContext.newInstance(SearchAndList.class); searchAndListPool = new UnmarshallerPool(MAX_POOL_SIZE, jaxbContext_SearchAndList); searchAndListPool.initialize();解组器 unmarshaller = null; InputStream in = makeCachedGETServerCall(finalURL); unmarshaller = searchAndListPool.getResource(); return (SearchAndList) unmarshaller.unmarshal(in);
-
@XmlRootElement(name="searchAndList") @XmlAccessorType(XmlAccessType.FIELD) public class SearchAndList extends ArrayList
implements Serializable{ private static final long serialVersionUID = 2447564738604L; @XmlElement 私有字符串 fvd;公共 SearchAndList() { super(); } public void setFvd(String fvd) { this.fvd = fvd; } 公共字符串 getFvd() { 返回 fvd; } @XmlElement(name="sol", type=Sol.class) public List getSol() { return this; } } -
问题的底部是显示关键字(java、xml、rest、jaxb)的阴影矩形。在那些下面是一个“编辑”链接。请使用该链接更改您的问题并将您的代码放在那里。如您所见,在 cmets 中代码非常难以阅读。
-
您能否检查并可能接受答案?