diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/tags/form/FormTag.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/tags/form/FormTag.java index 5aa9d23218..d0b76ff9b9 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/tags/form/FormTag.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/tags/form/FormTag.java @@ -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. *

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; } diff --git a/spring-webmvc/src/main/resources/META-INF/spring-form.tld b/spring-webmvc/src/main/resources/META-INF/spring-form.tld index 872f240ba0..a85779c571 100644 --- a/spring-webmvc/src/main/resources/META-INF/spring-form.tld +++ b/spring-webmvc/src/main/resources/META-INF/spring-form.tld @@ -5,7 +5,7 @@ version="2.0"> Spring Framework JSP Form Tag Library - 4.0 + 4.3 form http://www.springframework.org/tags/form @@ -131,8 +131,7 @@ true - Name of the model attribute under which the form object is exposed. - Defaults to 'command'. + DEPRECATED: Use "modelAttribute" instead. commandName false true diff --git a/src/asciidoc/appx-spring-form-tld.adoc b/src/asciidoc/appx-spring-form-tld.adoc index fd5ac0bdc7..9c99692409 100644 --- a/src/asciidoc/appx-spring-form-tld.adoc +++ b/src/asciidoc/appx-spring-form-tld.adoc @@ -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 diff --git a/src/asciidoc/web-view.adoc b/src/asciidoc/web-view.adoc index 7295e6621c..eecef7bece 100644 --- a/src/asciidoc/web-view.adoc +++ b/src/asciidoc/web-view.adoc @@ -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; ...

Name: - #springBind( "command.name" ) + #springBind("myModelObject.name")
@@ -331,7 +328,7 @@ configured earlier; ... Name: - <@spring.bind "command.name"/> + <@spring.bind "myModelObject.name"/>
@@ -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"] ---- - +
First Name: