springmvc form中 commandName和modelAttribute的疑問

  今天過代碼時,發現form 標籤的使用有點分歧,有些同事用 commandName,有些同事用 modelAttribue,這兩個屬性都是用來指定 formBackingObject ,到底該統一用哪個呢?

   查看tld文件得知類文件org.springframework.web.servlet.tags.form.FormTag  

   前去查驗發現

      

  public void setModelAttribute(String modelAttribute) {
        this.modelAttribute = modelAttribute;
    }

    protected String getModelAttribute() {
        return this.modelAttribute;
    }

    /** @deprecated */
    @Deprecated
    public void setCommandName(String commandName) {
        this.modelAttribute = commandName;
    }

    /** @deprecated */
    @Deprecated
    protected String getCommandName() {
        return this.modelAttribute;
    }
 已經不推薦使用commandName了,可以統一用modelAttribute屬性了。。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章