在后台SpringMVC的服务中,返回给前端的Json字符串时,字段名原来大写字母,变成了小写,导致前端js获取字段名失败。
解决方案:
在对象类中字段声明加@JsonProperty注解
@JsonProperty
private Integer DeviceId;
@JsonIgnore
public StringgetDeviceId() {
return deviceId;
}
@JsonIgnore
public void setDeviceId(String deviceId) {
this.deviceId = deviceId;
}
网友评论