第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

JAXB Unmarshalling - 未找到具有默認根元素的描述符...

JAXB Unmarshalling - 未找到具有默認根元素的描述符...

達令說 2022-06-23 15:45:22
我在將 api xml 響應解組為我創(chuàng)建的 POJO 時遇到問題。我確信 JAXB 上下文知道我的類,因為我能夠正確地編組它。POJOpackage com.bnh.element.misc.Requests;import javax.xml.bind.annotation.XmlAccessType;import javax.xml.bind.annotation.XmlAccessorType;import javax.xml.bind.annotation.XmlElement;import javax.xml.bind.annotation.XmlRootElement;@XmlRootElement(name = "selectionResponse")@XmlAccessorType(XmlAccessType.FIELD)public class SelectionResponse {    @XmlElement    boolean _hasErrors;    @XmlElement    int selectionIndex;    @XmlElement    String type;}試圖解組它:Object response = JAXB_CONTEXT.createUnmarshaller()    .unmarshal( new StringReader(xml) );拋出異常[異常 [EclipseLink-25008] (Eclipse Persistence Services - 2.6.4.v20160829-44060b6): org.eclipse.persistence.exceptions.XMLMarshalException 異常描述:具有默認根元素的描述符 { http://tripos.vantiv.com/ 2014/09/TriPos.Api }selectionResponse 在項目中找不到] 在 org.eclipse.persistence.jaxb.JAXBUnmarshaller.handleXMLMarshalException(JAXBUnmarshaller.java:1110)來自 API 的實際響應:<selectionResponse  xmlns:i="http://www.w3.org/2001/XMLSchema-instance"  xmlns="http://tripos.vantiv.com/2014/09/TriPos.Api">  <_errors />  <_hasErrors>false</_hasErrors>  <_links />  <_logs    xmlns:d2p1="http://schemas.microsoft.com/2003/10/Serialization/Arrays" i:type="Logs" />    <_type>selectionResponse</_type>    <_warnings />    <selectionIndex>0</selectionIndex>  </selectionResponse>編組對象時生成的字符串:<selectionResponse    xmlns:ns0="http://tripos.vantiv.com/2014/09/TriPos.Api">    <_hasErrors>false</_hasErrors>    <selectionIndex>0</selectionIndex></selectionResponse>任何幫助,將不勝感激。謝謝!
查看完整描述

1 回答

?
12345678_0001

TA貢獻1802條經(jīng)驗 獲得超5個贊

您的錯誤說明了很多:


異常描述:在項目中未找到具有默認根元素 { http://tripos.vantiv.com/2014/09/TriPos.Api }selectionResponse 的描述符]


xmlns您的 xml 中的默認值是:


  xmlns="http://tripos.vantiv.com/2014/09/TriPos.Api">

它不能被“猜測”,因此將命名空間添加到您的根元素聲明中,例如:


@XmlRootElement(name = "selectionResponse",

    namespace="http://tripos.vantiv.com/2014/09/TriPos.Api")

@XmlAccessorType(XmlAccessType.FIELD)

public static class SelectionResponse {

...


查看完整回答
反對 回復 2022-06-23
  • 1 回答
  • 0 關注
  • 106 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網(wǎng)微信公眾號