Populate Collection from Struts2 Form Submission

廉价感情. 提交于 2019-11-30 05:27:57
Roy Chan

If I understand it correctly, you just want different name for each hidden field?

<s:iterator value="bars" status="key">
    <s:hidden name="bar.foos[%{#key.index}].attr1" value="attr1" />
    <s:hidden name="bar.foos[%{#key.index}].attr2" value="attr2" />
</s:iterator>

which should give you the equivalent of

<input type="hidden" name="bar.foos[0].attr1" value="some value" />
<input type="hidden" name="bar.foos[0].attr2" value="some other value" />
<input type="hidden" name="bar.foos[1].attr1" value="some value" />
<input type="hidden" name="bar.foos[1].attr2" value="some other value" />

If you have proper getter/setter, it should set all the values when the form is being submitted.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!