Deprecated FormTag's "commandName" in favor of "modelAttribute"
Issue: SPR-14094
This commit is contained in:
parent
26bbb6e767
commit
2dae4d8134
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2015 the original author or authors.
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -147,7 +147,9 @@ public class FormTag extends AbstractHtmlElementTag {
|
|||
* Set the name of the form attribute in the model.
|
||||
* <p>May be a runtime expression.
|
||||
* @see #setModelAttribute
|
||||
* @deprecated as of Spring 4.3, in favor of {@link #setModelAttribute}
|
||||
*/
|
||||
@Deprecated
|
||||
public void setCommandName(String commandName) {
|
||||
this.modelAttribute = commandName;
|
||||
}
|
||||
|
@ -155,7 +157,9 @@ public class FormTag extends AbstractHtmlElementTag {
|
|||
/**
|
||||
* Get the name of the form attribute in the model.
|
||||
* @see #getModelAttribute
|
||||
* @deprecated as of Spring 4.3, in favor of {@link #getModelAttribute}
|
||||
*/
|
||||
@Deprecated
|
||||
protected String getCommandName() {
|
||||
return this.modelAttribute;
|
||||
}
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
version="2.0">
|
||||
|
||||
<description>Spring Framework JSP Form Tag Library</description>
|
||||
<tlib-version>4.0</tlib-version>
|
||||
<tlib-version>4.3</tlib-version>
|
||||
<short-name>form</short-name>
|
||||
<uri>http://www.springframework.org/tags/form</uri>
|
||||
|
||||
|
@ -131,8 +131,7 @@
|
|||
<rtexprvalue>true</rtexprvalue>
|
||||
</attribute>
|
||||
<attribute>
|
||||
<description>Name of the model attribute under which the form object is exposed.
|
||||
Defaults to 'command'.</description>
|
||||
<description>DEPRECATED: Use "modelAttribute" instead.</description>
|
||||
<name>commandName</name>
|
||||
<required>false</required>
|
||||
<rtexprvalue>true</rtexprvalue>
|
||||
|
|
|
@ -528,11 +528,6 @@ Renders an HTML 'form' tag and exposes a binding path to inner tags for binding.
|
|||
| true
|
||||
| HTML Required Attribute
|
||||
|
||||
| commandName
|
||||
| false
|
||||
| true
|
||||
| Name of the model attribute under which the form object is exposed. Defaults to 'command'.
|
||||
|
||||
| cssClass
|
||||
| false
|
||||
| true
|
||||
|
|
|
@ -292,13 +292,10 @@ directly, the files are called spring.vm / spring.ftl and are in the packages
|
|||
|
||||
[[view-simple-binding]]
|
||||
==== Simple binding
|
||||
In your html forms (vm / ftl templates) that act as the 'formView' for a Spring form
|
||||
In your HTML forms (vm / ftl templates) which act as a form view for a Spring MVC
|
||||
controller, you can use code similar to the following to bind to field values and
|
||||
display error messages for each input field in similar fashion to the JSP equivalent.
|
||||
Note that the name of the command object is "command" by default, but can be overridden
|
||||
in your MVC configuration by setting the 'commandName' bean property on your form
|
||||
controller. Example code is shown below for the `personFormV` and `personFormF` views
|
||||
configured earlier;
|
||||
Example code is shown below for the `personFormV`/`personFormF` views configured earlier:
|
||||
|
||||
[source,xml,indent=0]
|
||||
[subs="verbatim,quotes"]
|
||||
|
@ -308,7 +305,7 @@ configured earlier;
|
|||
...
|
||||
<form action="" method="POST">
|
||||
Name:
|
||||
#springBind( "command.name" )
|
||||
#springBind("myModelObject.name")
|
||||
<input type="text"
|
||||
name="${status.expression}"
|
||||
value="$!status.value"/><br>
|
||||
|
@ -331,7 +328,7 @@ configured earlier;
|
|||
...
|
||||
<form action="" method="POST">
|
||||
Name:
|
||||
<@spring.bind "command.name"/>
|
||||
<@spring.bind "myModelObject.name"/>
|
||||
<input type="text"
|
||||
name="${spring.status.expression}"
|
||||
value="${spring.status.value?default("")}"/><br>
|
||||
|
@ -818,7 +815,7 @@ The preceding JSP assumes that the variable name of the form backing object is
|
|||
[source,xml,indent=0]
|
||||
[subs="verbatim,quotes"]
|
||||
----
|
||||
<form:form commandName="user">
|
||||
<form:form modelAttribute="user">
|
||||
<table>
|
||||
<tr>
|
||||
<td>First Name:</td>
|
||||
|
|
Loading…
Reference in New Issue