I need to pass List as commandObject.
My code
public class Employee
{
List<Dept> dlist = new ArrayList<Dept>();
public List<Dept> getDlist()
{
return dlist;
}
public void setDlist(List<Dept> dlList)
{
this.dlist = dlist;
}
}
My jsp page
<c:forEach var="d" items="${dlist}">
<spring:bind path="dlist[0].projectId">
<input type="text" name="projectId" value='<c:out value="${d.projectId}" />' />
</spring:bind>
</c:forEach>
But it not passing, where i making mistake, can any suggest.
Your forEach loop is broken you should iterate over the elements in your List of the command Object.
Use form tags instead of spring:bind tags
Try like this
<c:forEach var="d" items="${command.dlist}" varStatus="status">
<form:input path="dlist[status.index].projectId" />
</c:forEach>
You will have to wrap the list in a class, which it looks like you have done with Employee ?
It should look something like this then :
<form:form id="frmEmployee" commandName="myEmployee" action="/Whatever/" method="POST">
<c:forEach items="${myEmployee.dlist}" var="dept" varStatus="status"><tr>
<tr><td>
<form:input path="dlist[status.index].projectId" id="title"/>