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属性了。。
 

猜你喜欢

转载自blog.csdn.net/zhaohefeijava/article/details/65444825
今日推荐