<tfoot id='QTz8z'></tfoot>
  • <i id='QTz8z'><tr id='QTz8z'><dt id='QTz8z'><q id='QTz8z'><span id='QTz8z'><b id='QTz8z'><form id='QTz8z'><ins id='QTz8z'></ins><ul id='QTz8z'></ul><sub id='QTz8z'></sub></form><legend id='QTz8z'></legend><bdo id='QTz8z'><pre id='QTz8z'><center id='QTz8z'></center></pre></bdo></b><th id='QTz8z'></th></span></q></dt></tr></i><div id='QTz8z'><tfoot id='QTz8z'></tfoot><dl id='QTz8z'><fieldset id='QTz8z'></fieldset></dl></div>
  • <small id='QTz8z'></small><noframes id='QTz8z'>

          <bdo id='QTz8z'></bdo><ul id='QTz8z'></ul>
        <legend id='QTz8z'><style id='QTz8z'><dir id='QTz8z'><q id='QTz8z'></q></dir></style></legend>

        从 Struts2 表单提交中填充集合

        时间:2023-09-24
      1. <tfoot id='fjs1M'></tfoot>
            <tbody id='fjs1M'></tbody>

            <bdo id='fjs1M'></bdo><ul id='fjs1M'></ul>

                1. <i id='fjs1M'><tr id='fjs1M'><dt id='fjs1M'><q id='fjs1M'><span id='fjs1M'><b id='fjs1M'><form id='fjs1M'><ins id='fjs1M'></ins><ul id='fjs1M'></ul><sub id='fjs1M'></sub></form><legend id='fjs1M'></legend><bdo id='fjs1M'><pre id='fjs1M'><center id='fjs1M'></center></pre></bdo></b><th id='fjs1M'></th></span></q></dt></tr></i><div id='fjs1M'><tfoot id='fjs1M'></tfoot><dl id='fjs1M'><fieldset id='fjs1M'></fieldset></dl></div>

                  <small id='fjs1M'></small><noframes id='fjs1M'>

                  <legend id='fjs1M'><style id='fjs1M'><dir id='fjs1M'><q id='fjs1M'></q></dir></style></legend>
                  本文介绍了从 Struts2 表单提交中填充集合的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我正在尝试从表单中填充 bean 列表:

                  I'm trying to populate a List of beans from a form:

                  public class Foo {
                     public String attr1;
                     public String attr2;
                  }
                  
                  public class Bar {
                     public List<Foo> foos;
                  }
                  
                  public class StrutsAction extends Action {
                     public Bar bar;
                  }
                  

                  那么在我的 Struts2 表单中,填充 Foo 的最佳方式是什么?直觉上,我想做:

                  So in my Struts2 form, what's the best way to populate Foo? Intuitively, I want to do:

                  <input type="hidden" name="bar.foos.attr1" />
                  

                  但这不起作用并且会导致冲突.我确定答案很简单,我忽略了它.

                  but that isn't working and would cause collisions. I'm sure the answer is very simple and I'm overlooking it.

                  推荐答案

                  如果我理解正确,您只是希望每个隐藏字段的名称不同?

                  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>
                  

                  这应该给你相当于

                  <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" />
                  

                  如果你有合适的getter/setter,它应该在提交表单时设置所有的值.

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

                  这篇关于从 Struts2 表单提交中填充集合的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:Struts2 与 Spring 3 下一篇:如何禁用窗体的 struts 2 表生成?

                  相关文章

                  <tfoot id='fBk1o'></tfoot>
                    <bdo id='fBk1o'></bdo><ul id='fBk1o'></ul>

                2. <i id='fBk1o'><tr id='fBk1o'><dt id='fBk1o'><q id='fBk1o'><span id='fBk1o'><b id='fBk1o'><form id='fBk1o'><ins id='fBk1o'></ins><ul id='fBk1o'></ul><sub id='fBk1o'></sub></form><legend id='fBk1o'></legend><bdo id='fBk1o'><pre id='fBk1o'><center id='fBk1o'></center></pre></bdo></b><th id='fBk1o'></th></span></q></dt></tr></i><div id='fBk1o'><tfoot id='fBk1o'></tfoot><dl id='fBk1o'><fieldset id='fBk1o'></fieldset></dl></div>

                  <small id='fBk1o'></small><noframes id='fBk1o'>

                  <legend id='fBk1o'><style id='fBk1o'><dir id='fBk1o'><q id='fBk1o'></q></dir></style></legend>