开发者

Castor Integers with empty tags become Zero. Any way to stop that?

Any w开发者_JS百科ay to stop Castor from converting empty tags to Zero?

<AMID></AMID>

This becomes a Zero Integer but I really want it to blow out or become a -1 so I can pick it up later.

I tried a handler but it seems to be already an Integer when it comes in...


You can use a

public void setAmid(String amid) {
...
} 

setter, and cast the number manually to an integer. You also need to define a set-method attribute in the mapping file like this:

<field name="amid" type="string" set-method="setAmid" ...>

This is to avoid Castor's confusion when unmarshalling the object.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜