I am looking to find out the difference between the spring:bind and form:form tag libraries when submitting a form.
A snippet of my JSP is as follows:
<form:form modelAttribute="testRulesForm">
....
<td>
<form:checkbox path="rules[${counter.index}].isActive" value="rules[${counter.index}].isActive"/>
</td>
<td>
<form:select path="rules[${counter.index}].leftCondition.name">
<form:options items="${testRulesForm.ruleAttributes}" itemLabel="name" itemValue="name" />
</form:select>
</td>
<td>
<form:select path="rules[${counter.index}].operator">
<form:options itemLabel="operator" itemValue="operator" />
</form:select>
</td>
....
Seeing as I have my path variable specified and this will be bound to my modelAttribute, does this mean that I do not need spring:bind?
Thanks
Form Handling Support in Spring MVC Model: basically a POJO (Plain Old Java Object) class is created to bind form fields with properties of the object. This object will be put into the model (model object).
The spring:bind tag provides you with support for evaluation of the status of a certain bean or bean property.
One of the most important Spring MVC annotations is the @ModelAttribute annotation. @ModelAttribute is an annotation that binds a method parameter or method return value to a named model attribute, and then exposes it to a web view.
A springform pan is a round cake pan that features a removable bottom and sides. The sides are held together with an interlocking band that can be opened and removed once your baked good is out of the oven, leaving your cake on the base.
Normally you don't need to use <spring:bind>
if you already use form
taglib.
They do basically the same with respect to model attributes, but tags from form
taglib also generate HTML form markup, whereas with <spring:bind>
you need to generate markup yourself.
The following code with form
tags:
<form:form modelAttribute = "foo">
<form:input path = "bar" />
</form:form>
is similar to the following code with <spring:bind>
:
<spring:bind path = "foo">
<form method = "get">
<spring:bind path = "bar">
<input name = "bar" value = "${status.displayValue}" />
</spring:bind>
</form>
</spring:bind>
<spring:bind>
is useful when you need something customized, that cannot be achieved by form
taglib.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With