以春天的形式绑定一套 [英] Bind a set in a spring form

查看:155
本文介绍了以春天的形式绑定一套的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



在我的命令类 AInstance 中,我将set的定义设置为

 私人套餐< BParameter> bParameters = new HashSet< BParameter>(); 

在jsp中,我将它绑定为

 < form:input path =bParameters/> 
< form:input path =bParameters/>

由于它的Java Set ,所以可能有很多字段。当我提交此表单时,我试图将 Set 设为:

  Set< BParameter> bParameters = aInstance.getBParameters(); 

我将设为设为0尺寸。



我也尝试绑定为

 < form:input path =bParameters [$ {itemsRow.index}]。bParmvalues [0] .parmValue/> 

但得到异常

  bean类的无效属性'bParameters [0]'

问题是什么与我的绑定?

解决方案

在控制器中使用列表。

 <输入名称= bParameters [{idx}]。bParmvalues [0] .parmValue/> 


I am trying to bind a spring form with a set in the command object.

In my command class AInstance I defined set as

private Set<BParameter> bParameters = new HashSet<BParameter>();

In jsp I bind it as

<form:input path="bParameters " />
<form:input path="bParameters " />

As its a Java Set so there may be many fields. When I submit this form I tried to get Set as:

Set<BParameter> bParameters = aInstance.getBParameters();

I got Set with a 0 size.

I also tried to bind as

<form:input path="bParameters[${itemsRow.index}].bParmvalues[0].parmValue" />

but got exception

Invalid property 'bParameters[0]' of bean class

What is the problem with my binding?

解决方案

Use an List in the controller.

In the view you can use this straight html (not sure if this works with spring tags).

<input name="bParameters[{idx}].bParmvalues[0].parmValue" />

这篇关于以春天的形式绑定一套的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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