Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/spring-mvc/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Spring mvc @spring.formInput在#列表迭代器中_Spring Mvc_Freemarker - Fatal编程技术网

Spring mvc @spring.formInput在#列表迭代器中

Spring mvc @spring.formInput在#列表迭代器中,spring-mvc,freemarker,Spring Mvc,Freemarker,如何解析@spring.formInput中的#list您尝试过中间赋值吗?我在其他StackOverflow页面上看到此问题,如: 以下变通方法对我来说很有效,但非常难看: <#list flowList as flow> <#assign flowDate = flow.createDatetime /> <@spring.formInput "flowDate" /> <\#list> 发布上述表单时,您需要确保流列表预先填

如何解析
@spring.formInput
中的
#list

您尝试过中间赋值吗?我在其他StackOverflow页面上看到此问题,如:


以下变通方法对我来说很有效,但非常难看:

<#list flowList as flow>
   <#assign flowDate = flow.createDatetime />
   <@spring.formInput "flowDate" />
<\#list>


发布上述表单时,您需要确保流列表预先填充了空流。或者,只需使用Spring的
AutoPopulatingList
作为流列表实现。

对于Spring绑定对象,必须提供准确的引用。因此,您需要在标记中添加索引。当您将表单发回并希望flowlist对象作为控制器方法中的请求主体时,需要这样做

<#list flowList as flow>
    <#assign index=flowList?seq_index_of(flow)>
    <@spring.formInput "flowList[${index}].createDatetime" />
</#list>

渲染后,如果查看HTML,它将如下所示

<#list flowList as flow>
    <@spring.formInput "flowList[${flow_index}].createDatetime" />
</#list>

<#list flowList as flow>
    <#assign index=flowList?seq_index_of(flow)>
    <@spring.formInput "flowList[${index}].createDatetime" />
</#list>
<#list flowList as flow>
    <@spring.formInput "flowList[${flow_index}].createDatetime" />
</#list>
<input type="text" id="flowList0.createDatetime" name="flowList[0].createDatetime" value="..." />