Spring MVC:弹簧之间的区别:bind和form:form [英] Spring MVC: Difference between spring:bind and form:form
问题描述
我的JSP代码片段如下所示:
:
< form:form modelAttribute =testRulesForm>
....
< td>
< form:checkbox path =rules [$ {counter.index}]。isActivevalue =rules [$ {counter.index}]。isActive/>
< / td>
< td>
< form:select path =rules [$ {counter.index}]。leftCondition.name>
< form:options items =$ {testRulesForm.ruleAttributes}itemLabel =nameitemValue =name/>
< / form:select>
< / td>
< td>
< form:select path =rules [$ {counter.index}]。operator>
< form:options itemLabel =operatoritemValue =operator/>
< / form:select>
< / td>
....
看到我已经指定了路径变量,到我的modelAttribute,这是否意味着我不需要spring:bind?
谢谢
如果您已经使用 它们在模型属性方面基本相同,但来自 form $ c $>,通常您不需要使用
标签:< spring:bind>
c> taglib。
form
taglib的标签也会生成HTML表单标记,而使用< spring:bind>
,您需要自己生成标记。
$ p $ lt; code>< form:form modelAttribute =foo> $ c> form
< form:input path =bar/>
< / form:form>
与下面的代码类似:< spring:bind>
:
< spring:bind path =foo>
< form method =get>
< spring:bind path =bar>
< input name =barvalue =$ {status.displayValue}/>
< / spring:bind>
< / form>
< / spring:bind>
< spring:bind>
很有用当你需要自定义的东西时,
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
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.
这篇关于Spring MVC:弹簧之间的区别:bind和form:form的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!