dwr出现error marshalling data,see the logs for more details问题

js页面:

var obj = {};
obj.id='11111';
obj.address='sdfaf';
obj.area = 100.0;
obj.unitprice = 10000.0;
obj.ispassed = true;
transBuildingXController.saveTransBuildingX(obj,function(data){
	alert(data);
})

 

后台java的transBuildingXController方法:

public TransBuildingX saveTransBuildingX(TransBuildingX transBuilding)
{
    return transBuilding
}   

 

另外TransBuildingX的类:

public class TransBuildingX implements java.io.Serializable {
private String id;
private Double area;
 public String getId() {
        return this.id;
    }
    
    public void setId(String id) {
        this.id = id;
    }
    public Double getArea() {
        return this.area*100;
    }
    
    public void setArea(Double area) {
        this.area = area;
    }
}

  

这时用dwr提交时会出现错误“error marshalling data,see the logs for more details”
需要将Double改为double,或者将“return this.area*100;”改为“return this.area;

因为如果是Double时默认值为NULL,而double值时默认为0.0,而null*100会出错的。

你可能感兴趣的:(JavaScript,java,DWR)