設置DTO的變量的是有isXXX的值的,但是使用fastjson序列化后,這幾個變量就不見了。
{
"cityid":1,
"cityname":"上海",
"clienttype":"iphone",
"glat":139.78120482626642,
"glng":35.625721171054344,
"msgid":"19142020721848452861509443234119",
"overseas":false,
"strangeLand":true,
"timestamp":1509443234119
}
很奇怪,為什么isXXX序列化后就沒有了呢,然后就去排查,發現默認的setter和getter方法,如果是boolean變量的話默認的get方法用的isxxx
public boolean isbackground() {
return isbackground;
}
public void setIsbackground(boolean isbackground) {
this.isbackground = isbackground;
}
這樣其實就沒有isbackground這個變量的get方法,所以只需要修改isbackground的get方法就可以了。
public boolean getIsbackground() {
return isbackground;
}
public void setIsbackground(boolean isbackground) {
this.isbackground = isbackground;
}
這樣就好了。。。
