为何后台传的属性值,和前台展示的属性值不一致

现象前端

后台:java

前台:this

JavaBean对象 code

private Boolean success;
	private Boolean isSuccess;
	private boolean parent;
	private boolean isParent1;

    public Boolean getSuccess() {
		return success;
	}


	public void setSuccess(Boolean success) {
		this.success = success;
	}


	public Boolean getIsSuccess() {
		return isSuccess;
	}


	public void setIsSuccess(Boolean isSuccess) {
		this.isSuccess = isSuccess;
	}


	public boolean isParent() {
		return parent;
	}


	public void setParent(boolean parent) {
		this.parent = parent;
	}


	public boolean isParent1() {
		return isParent1;
	}

	public void setParent1(boolean isParent1) {
		this.isParent1 = isParent1;
	}

从上面能够看出:对象

Boolean类型的属性,仍是get/set后加属性名,这样对Spring MVC返回bean的属性值不会有影响。get

boolean类型的属性,get方法是is属性名(若是属性名中带有is,会过滤掉),set方法是set属性名(若是属性名中带有is,会过滤掉)。每次Spring MVC返回的时候会先找is类型的get方法,若是没有就去直接找get。因此会致使后台返回的属性名跟前端不一致。class

相关文章
相关标签/搜索