使用@XMLJavaTypeAdapters进行JAXB解组
我有三节课
@XmlRootElement public class GeofenceParameter{ private GeofenceCenterAddress geofenceCenterAddress; private GeofenceCenterCoordinates geofenceCenterCoordinates; } public class GeofenceCenterAddress extends GeofenceParameter{ } public class GeofenceCenterCoordinate extends GeofenceParameter{ } 我已经制作了两个不同的XmlAdapter扩展类来对GeofenceCenterAddress和GeofenceCentereCoordinate中的Geofence Paramtere进行编组和解组 Class forGeofenceCenterCoordinate extends XmlAdapter<ValueType,BoundType>{ } Class forGeofenceCenterAddress extends XmlAdapter<ValueType,BoundType>{ } 根据Soap请求发送,从GeofenceParamter获取相关的GeofenceCenterAddress或GeofenceCenterCoordinate类的实例. 为此我在package-info.java文件中使用了注释@XmlJavaTypeAdapters {(@ XmlJavaTypeAdapter(type = forGeofenceCenterCoordinate)),@ XmlJavaTypeAdapter(type = forGeofenceCenterAddress)} 但是在Web Service中,它将给我一个类的实例,我在注释中指定了这个类,即@XmlJavaTypeAdapter(type = forGeofenceCenterCoordinate)类,而不是来自GeofenceParamter的@XmlJavaTypeAdapter(type = forGeofenceCenterAddress). 你能不能在JAXB继承编组和解组中帮助我修改第二类的实例. 提前致谢 解决方法
我不记得使用过@XmlJavaTypeAdapters,但@XmlJavaTypeAdapter注释的正常用法只是@XmlJavaTypeAdapter(forGeofenceCenterCoordinate.class).
仅当在包级别应用注释时,才需要type参数. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |