How to set a default value when a field is null in jibx binding?

一笑奈何 提交于 2019-12-13 04:46:30

问题


I would like to set a default constant value to a particular value node in JiBX when the corresponding field value is null. Is this possible and if so, how?


回答1:


You can use the element 'default' ... for example:

<value name="YourElementName" field="fieldName" default="default-value" usage="optional" />

This is only allowed for 'optional' elements.

See the description here: http://jibx.sourceforge.net/details/binding-attributes.html#string



来源:https://stackoverflow.com/questions/6250615/how-to-set-a-default-value-when-a-field-is-null-in-jibx-binding

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!