0

I have a class A having field of List of class B

class A{

       private String x;
       private String y;
       private List<B> list;
}

class B{

      private string x1;
      private String y1;
}

In JSP, I have a form where there is input field for x and y and c:foreach select for B.

My question is that how to make a form so that i can pass a list of objects of type B inside A and send it to the spring controller.

So far i am getting a list with only one element.

1 Answer 1

3

You can use array. example :

<c:forEach items="${a.list}" varStatus="i">
    <tr>
        <td><form:input path="list[${i.index}].x1" type="text" /></td>
        <td><form:input path="list[${i.index}].y1" type="text" /></td>
    </tr>
</c:forEach>

and for add and delete List rows in jsp i used javascript..

Sign up to request clarification or add additional context in comments.

1 Comment

You are absolutely correct....javascript needs to come into the picture....i did it already......anyways thanks for your reply

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.