modelAttribute and commandName atributes in form tag in Spring

查了一些源码,发现commandName其实是set get modelAttributeorg.springframework.web.servlet.tags.form.FormTag

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
public class FormTag extends AbstractHtmlElementTag {

//other codes

/** The default attribute name: "command" */
public static final String DEFAULT_COMMAND_NAME = "command";

private String modelAttribute = DEFAULT_COMMAND_NAME;

/**
* Set the name of the form attribute in the model.
* <p>May be a runtime expression.
*/
public void setModelAttribute(String modelAttribute) {
this.modelAttribute = modelAttribute;
}

/**
* Get the name of the form attribute in the model.
*/
protected String getModelAttribute() {
return this.modelAttribute;
}

/**
* Set the name of the form attribute in the model.
* <p>May be a runtime expression.
* @see #setModelAttribute
*/
public void setCommandName(String commandName) {
this.modelAttribute = commandName;
}

/**
* Get the name of the form attribute in the model.
* @see #getModelAttribute
*/
protected String getCommandName() {
return this.modelAttribute;
}

//other codes
}