0

Here is my code snippet which adds an arraylist to model attribute

 List<ViewBillResult> viewResult = viewBillBusiness.searchViewBill(stBillId);
        model.addAttribute("viewResult", viewResult);

I have accessed each BillSearchResult attribute's on jsp page as follows

<c:forEach var="viewLis" varStatus = "number" items="${viewResult}" >
<tr >

      <td><form:hidden  path="viewList[${number.index}].billNo"/></td>
       </tr>
 </c:forEach>

How can i access the first index of searchResult array without using forEach(I want to access viewResult.get(0).billNo )

3 Answers 3

1

You could use ${viewResult[0].billNo}

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

Comments

0

Like here :

<td><form:hidden  path="<%= viewResult.get(0).billNo %>"/></td>

Comments

0

It depends how you want to access it. If you want to just read it use the solution by Reimeus. If you want to write into the first element and your appended code works then use :
<form:hidden path="viewResult[0].billNo"/>

Comments

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.