XStream中的序列化问题 [英] Serialization Issues in XStream
问题描述
所以我在序列化Java代码时遇到问题.这是一个网络抓取工具,它从我学校的选课网站上抓取我正在从事的项目的页面,并且我试图将指定主题的所有班级"信息输出到XML文件中.问题是,有些类具有多个部分,而不仅仅是重写这些文件名和浪费空间,我希望它们全部都保留在XML中名为"Sections"的部分下.知道我的代码有什么问题吗?这是要点的链接,我不想使用我的代码来拉伸页面:要点 >
So I am having a problem serializing my Java code. This is a web scraper, scraping pages from our school's course selection website for a project I'm working on and I'm trying to output all the Class information for the designated Subject in an XML file. The problem is, some classes have more than one section, and rather than just re-writing these file names and wasting space, I wanted them all to stay under a section called "Sections" in my XML. Any idea what is wrong with my code? Here's a link to the gist, I don't want to stretch the page with my code: Gist
推荐答案
通过xstream
处理List
有点棘手.您需要为sections
Handling List
through xstream
is bit tricky. You need to add an implicitCoolection
for sections
//xstream.alias("list", Class.class);
xstream.addImplicitCollection(Class.class, "sections");
希望这会有所帮助!
这篇关于XStream中的序列化问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!