xml 日期和时间字符串上的 XStream 转换异常
我尝试转换的 XML 如下所示:
<?xml version="1.0" encoding="utf-8"?>
<ArrayOfTrafiklage>
<Trafiklage>
<Utgangsdatum xmlns="">2011-10-14T00:00:00+02:00</Utgangsdatum>
</Trafiklage>
<Trafiklage>
<Utgangsdatum xmlns="">2011-10-15T00:00:00+02:00</Utgangsdatum>
</Trafiklage>
<Trafiklage>
<Utgangsdatum xmlns="">2011-10-16T00:00:00+02:00</Utgangsdatum>
</Trafiklage>
</ArrayOfTrafiklage>
我要转换的代码如下所示:
XStream xstream = new XStream(new DomDriver());
xstream.alias("ArrayOfTrafiklage", Trafiklagen.class);
xstream.alias("Trafiklage", StationInfoModel.class);
Trafiklagen trafiklagen = (Trafiklagen) xstream
.fromXML(result);
StationInfoModel.java 如下所示:
public class StationInfoModel
{
private Date Utgangsdatum;
}
当运行 fromXML 命令时,我收到此异常:
com.thoughtworks.xstream.converters.ConversionException: Utgangsdatum : Utgangsdatum
---- Debugging information ----
message : Utgangsdatum
cause-exception : com.thoughtworks.xstream.mapper.CannotResolveClassException
cause-message : Utgangsdatum
class : java.util.ArrayList
required-type : java.util.ArrayList
converter-type : com.thoughtworks.xstream.converters.collections.CollectionConverter
path : /ArrayOfTrafiklage/Trafiklage/Utgangsdatum
class[1] : org.rickardp.trainstatus.Models.Trafiklagen
converter-type[1] : com.thoughtworks.xstream.converters.reflection.ReflectionConverter
version : 0.0
-------------------------------
有人知道我做错了什么吗?
The XML i trying to convert looks like:
<?xml version="1.0" encoding="utf-8"?>
<ArrayOfTrafiklage>
<Trafiklage>
<Utgangsdatum xmlns="">2011-10-14T00:00:00+02:00</Utgangsdatum>
</Trafiklage>
<Trafiklage>
<Utgangsdatum xmlns="">2011-10-15T00:00:00+02:00</Utgangsdatum>
</Trafiklage>
<Trafiklage>
<Utgangsdatum xmlns="">2011-10-16T00:00:00+02:00</Utgangsdatum>
</Trafiklage>
</ArrayOfTrafiklage>
My code to convert looks like this:
XStream xstream = new XStream(new DomDriver());
xstream.alias("ArrayOfTrafiklage", Trafiklagen.class);
xstream.alias("Trafiklage", StationInfoModel.class);
Trafiklagen trafiklagen = (Trafiklagen) xstream
.fromXML(result);
The StationInfoModel.java looks like:
public class StationInfoModel
{
private Date Utgangsdatum;
}
And i getting this Exception when it running the fromXML command:
com.thoughtworks.xstream.converters.ConversionException: Utgangsdatum : Utgangsdatum
---- Debugging information ----
message : Utgangsdatum
cause-exception : com.thoughtworks.xstream.mapper.CannotResolveClassException
cause-message : Utgangsdatum
class : java.util.ArrayList
required-type : java.util.ArrayList
converter-type : com.thoughtworks.xstream.converters.collections.CollectionConverter
path : /ArrayOfTrafiklage/Trafiklage/Utgangsdatum
class[1] : org.rickardp.trainstatus.Models.Trafiklagen
converter-type[1] : com.thoughtworks.xstream.converters.reflection.ReflectionConverter
version : 0.0
-------------------------------
Do someone has any idea what i doing wrong?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
用这个
Use this