Reputation: 19854
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
Upvotes: 14
Views: 17625
Reputation: 242706
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.
Upvotes: 27