爲何後臺傳的屬性值,和前臺展示的屬性值不一致

現象前端

後臺: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

相關文章
相關標籤/搜索