列表的弹簧输入路径 [英] spring input path for list

查看:65
本文介绍了列表的弹簧输入路径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在jsp中使用Spring输入路径

I am using Spring input path in jsp

例如:

<div class="cell label"> 
    <form:label path="order.paymentTransactions.payerEmail">Payer Mail</form:label>
</div> 
<div class="cell"> 
    <form:input path="order.paymentTransactions.payerEmail" name="payerEmail"/>
</div> 

在这里,订单是我的主要对象,在订单内部,paymentTransaction是一个List,我必须在payerEmail中输入要通过dao进行检查的数据.

here, order is my main object and inside order, paymentTransaction is a List, i have to input data to check through dao in payerEmail.

但是它向我显示错误和无效的路径.请建议我一个在jsp中定义输入路径的好方法.谢谢

But it showing error to me and invalid path. Please suggest me a good way to define the input path in jsp. thanks

推荐答案

在Spring中映射bean列表时,很难提供path属性.您可以将<form:input>替换为纯HTML <input>.

While mapping a list of bean in Spring, it is difficult to provide path attribute. You can replace the <form:input> with plain html <input>.

<input name="order.paymentTransactions[0].payerEmail" />

这是在Spring MVC中将List映射为表单对象的完整示例

Here's a complete example to map List as form object in Spring MVC

示例: Spring MVC:多行表单使用列表提交豆类

上面的示例还讨论了为什么在使用列表时难以使用<form:input>的原因.这是因为如果您尝试使用如下所示的内容:

The above example also discuss why it is difficult to use <form:input> while working with Lists. Its because if you try to use something like below:

<form:input path="order.paymentTransactions[0].payerEmail" name="payerEmail"/>

Spring会将其简单地呈现为HTML:

Spring will simple render this as HTML:

<input name="order.paymentTransactions0.payerEmail" />

忽略括号[].

因此不可能使用<form:input>映射列表.

Thus its impossible to use <form:input> for mapping List.

这篇关于列表的弹簧输入路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆