簡體   English   中英

簡單的 XML 框架和 Android - 奇怪的 class 屬性

[英]Simple XML Framework and Android - strange class attribute

我正在嘗試將 Simple XML 庫與 Android 一起使用,但出現了一些錯誤 ( http://pastebin.com/7Nrk1esD ),其中主要錯誤是:

"org.eclipse.persistence.indirection.IndirectList in loader dalvik.system.PathClassLoader..."

必須反序列化的 Model 也被 rest-server 用來生成必要的 XML,還有一些 JPA 注釋,如下所示:

@OneToMany
@ElementList(required = false)
private List<Substance> substances = new ArrayList<>();

該行產生以下 xml output:

<substances class="org.eclipse.persistence.indirection.IndirectList">
...
</substances>

在這里,我現在看到錯誤的來源 - Android 不知道 org.eclipse.persistence:但我現在的問題是:為什么會生成行class="...IndirectList"以及如何更改它以避免Android 應用程序中的錯誤?

PS:我用的是simple 2.6.2

提前致謝!

這里找到答案:

Strategy strategy = new TreeStrategy("clazz", "len");
Serializer serializer = new Persister(strategy);

但是我只在 Android 客戶端中使用這個片段來反序列化而不是在服務器中序列化 model。

試試這個

@OneToMany
@Path("substances")
@ElementList(required = false, inline=false)
private List<Substance> substances = new ArrayList<>();

這應該工作。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM