平常用的时候form tag都是用commandName来设定form的对象上下文。
看Spring例子的时候又发现了个modelAttribute,有着一样的功能。在国外的网站查了查,有如此的解释
发现modelAttribute取代了commandName属性
看Spring例子的时候又发现了个modelAttribute,有着一样的功能。在国外的网站查了查,有如此的解释
/**
* Set the name of the form attribute in the model.
* May be a runtime expression.
* @see #setModelAttribute
*/
public void setCommandName(String commandName) {
this.modelAttribute = commandName;
}
发现modelAttribute取代了commandName属性
<form:form modelAttribute="user">
<table>
<tr>
<td>First Name:</td>
<td>
<input path="firstName"/>
</td>
</tr>
<tr>
<td>Last Name:</td>
<td>
<input path="lastName"/>
</td>
</tr>
<tr>
<td colspan="2">
<input type="submit" value="Save Changes"/>
</td>
</tr>
</table>
</form:form>