用于对象集合的表单的Freemarker语法(Spring 3 MVC)

Ben*_*mes 5 freemarker spring-mvc

我有一个命令bean( FooList),它有一个属性是一个集合(ListFoo豆).

我正在尝试创建一个可以同时编辑所有Foos 的表单.我已经找到了许多使用JSP来完成此操作的示例,但是我将这些示例转换为Freemarker语法时遇到了问题.

在我的Freemarker模板中,我可以轻松地遍历集合:

[#list fooList.foos as foo]
...
[/#list]
Run Code Online (Sandbox Code Playgroud)

我也可以Foo通过索引来引用一个特定的:

[@spring.bind "fooList.foos[0].name" /]
<input type="text" name="${spring.status.expression}" value="${spring.status.value?default('')}"/>
Run Code Online (Sandbox Code Playgroud)

但是,我还没有弄清楚我如何同时做两件事,将所有的Foos 绑定到形成元素.

这是一次失败的天真尝试:

[#list fooList.foos as foo]
    [@spring.bind "fooList.foos[foo_index].name" /]
    ...
[/#list]
Run Code Online (Sandbox Code Playgroud)

(就其本身而言,${foo_index}在循环内部工作.)

谁能指出我正确的方向?

谢谢.

Ste*_*erl 3

刚刚遇到了同样的问题。这对我有用:

[#list fooList.foos as foo]
  <#assign item>fooList.foos[${foo_index}].name</#assign>
  [@spring.bind item /]
  ...
[/#list]
Run Code Online (Sandbox Code Playgroud)