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.
精彩评论