1

我正在使用 jaxb moxy 解组,并且我的 java 对象在 getter 方法中有一些逻辑来设置数组中的值。因此在解组时面临问题,因为在解组时 jaxb 框架会调用 getter 方法两次。有没有办法避免这个getter方法被调用两次?可以在绑定 xml 中设置一些东西来避免这个 getter 调用进行空检查吗?

4

1 回答 1

0

You could specify @XmlAcessorType(XmlAccessType.FIELD) so that MOXy (or and JAXB implementation) uses the field directly instead of the property (get/set methods). With this access type you will want to put the annotations on the fields.

For More Information

于 2013-05-20T15:00:27.270 回答