今天過代碼時,發現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屬性了。。