I am using Spring input path in jsp
ex:
<div class="cell label">
<form:label path="order.paymentTransactions.payerEmail">Payer Mail</form:label>
</div>
<div class="cell">
<form:input path="order.paymentTransactions.payerEmail" name="payerEmail"/>
</div>
here, order is my main object and inside order, paymentTransaction is a List, i have to input data to check through dao in payerEmail.
But it showing error to me and invalid path. Please suggest me a good way to define the input path in jsp. thanks
While mapping a list of bean in Spring, it is difficult to provide path attribute. You can replace the <form:input>
with plain html <input>
.
<input name="order.paymentTransactions[0].payerEmail" />
Here's a complete example to map List as form object in Spring MVC
Example: Spring MVC: Multiple Row Form Submit using List of Beans
The above example also discuss why it is difficult to use <form:input>
while working with Lists. Its because if you try to use something like below:
<form:input path="order.paymentTransactions[0].payerEmail" name="payerEmail"/>
Spring will simple render this as HTML:
<input name="order.paymentTransactions0.payerEmail" />
Ignoring the brackets [ ].
Thus its impossible to use <form:input>
for mapping List.
We can do mapping of list through spring . Please update in your site. Thank you.
Example:
<c:forEach var="marksList" items="${personDTO.marksList}" varStatus="status">
<form:input path="marksList[${status.index}].hindi" />
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With