xStream转javaBean
不明白xsi:nil是什么意思。
报文ComSerial标签里的xsi:nil="true"属性取不到值,如果改成nil="true",javaBean里的nil注解改为@XStreamAlias("nil")就可以了
xsi:在这里起了什么作用,改怎么调,求高手!!!昨完了才能回去。。。不然周末还得加班啊
<PackageList>
<Package>
<Header>
<!-- 唯一编码(必填) -->
<UUID>cff6105b-081b-466e-aee8-7aac06f9cfb5</UUID>
<!--流水号(非必填)-->
<ComSerial xsi:nil="true"/>
</Header>
</Package>
</PackageList>
这里省略Header等javaBean。直接看<ComSerial xsi:nil="true"/>对应的javabean。
@XStreamConverter(value = ToAttributedValueConverter.class, strings = { "content" })
@XStreamAlias("ComSerial")
public class ComSerial {
@XStreamAsAttribute
@XStreamAlias("xsi:nil")
private String nil;
private String content = "";
/**
* @return the content
*/
public String getContent() {
return content;
}
/**
* @param content
* the content to set
*/
public void setContent(String content) {
this.content = content;
}
/**
* @return the nil
*/
public String getNil() {
return nil;
}
/**
* @param nil the nil to set
*/
public void setNil(String nil) {
this.nil = nil;
}
}
这是报错结果。
com.thoughtworks.xstream.io.StreamException: : Error on line 1 of document : The prefix "xsi" for attribute "xsi:nil" associated with an element type "ComSerial" is not bound. Nested exception: The prefix "xsi" for attribute "xsi:nil" associated with an element type "ComSerial" is not bound.