开发者

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

开发者 https://www.devze.com 2023-03-31 07:50 出处:网络
Any w开发者_JS百科ay to stop Castor from converting empty tags to Zero? <AMID></AMID>

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

精彩评论

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