问题说明
boolean类型的变量命名由is开头时,IDEA自动生成get、set方法的问题。
Java开发手册中对实体类类中布尔类型的变量命名有明确规定。布尔类型的变量不要加is前缀。
布尔类型的参数是以“is”开头,自动生成的get,set方法就会有问题:
public class TestParam {
private Integer id;//id
private String aName;//名称
private Boolean isUse;//启用/停用
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getaName() {
return aName;
}
public void setaName(String aName) {
this.aName = aName;
}
public Boolean getUse() {
return isUse;
}
public void setUse(Boolean use) {
isUse = use;
}
}
如果实体类中字段一定要用is开头
在字段上加上注解@JsonProperty("use")
import com.fasterxml.jackson.annotation.JsonProperty;
public class TestParam {
private Integer id;//id
private String aName;//名称
@JsonProperty("use")
private Boolean isUse;//启用/停用
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getaName() {
return aName;
}
public void setaName(String aName) {
this.aName = aName;
}
public Boolean getUse() {
return isUse;
}
public void setUse(Boolean use) {
isUse = use;
}
}
前端参数use
就可以了