Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Maybe this answersyour question:</p> <p><strong>CONTROLLER :</strong></p> <pre><code>@Controller("/") public class FooController{ //returns the ModelAttribute fooListWrapper with the view fooForm @RequestMapping(value = "/FOO", method = RequestMethod.GET) public String getFooForm(Model model) { FooListWrapper fooListWrapper = new FooListWrapper(); fooListWrapper.add(new Foo()); fooListWrapper.add(new Foo()); //add as many FOO you need model.addAttribute("fooListWrapper", fooListWrapper); return "fooForm"; } @RequestMapping(value = "/FOO", method = RequestMethod.POST) public String postFooList(@ModelAttribute("fooListWrapper")FooListWrapper fooListWrapper, Model model) { //........... } } </code></pre> <p><strong>FOO LIST WRAPPER :</strong></p> <pre><code>public class FooListWrapper { private List&lt;Foo&gt; fooList; public FooListWrapper() { this.fooList = new ArrayList&lt;Foo&gt;(); } public List&lt;Foo&gt; getFooList() { return fooList; } public void setFooList(List&lt;Foo&gt; fooList) { this.fooList = fooList; } public void add(Foo foo) { this.fooList.add(foo); } } </code></pre> <p><strong>FOO CLASS :</strong></p> <pre><code>public class Foo { private String name; public Foo() { } public String getName() { return name; } public void setName(String name) { this.name = name; } } </code></pre> <p><strong>JSP VIEW (name = fooForm):</strong></p> <pre><code>&lt;c:url var="fooUrl" value="/FOO"/&gt; &lt;form:form id="frmFoo" action="${fooUrl}" method="POST" modelAttribute="fooListWrapper"&gt; &lt;c:forEach items="${fooListWrapper.fooList}" varStatus="i"&gt; &lt;form:input path="fooList[${i.index}].name" type="text"/&gt; &lt;/c:forEach&gt; &lt;button&gt;submit&lt;/button&gt; &lt;/form:form&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload