0

I am not very good in JSTL. I would be glad to get some help.

I have below Map object in my java class:

Map<Integer, Result[]> qrCodeMap = new HashMap<Integer, Result[]>();
Result qrCodeResult[] = null;

...............(some lines of code)

for (int i = 0; i < pageCount; i++) 

{
..............
qrCodeResult = new QRCodeMultiReader().decodeMultiple(binaryBitmap, hintMap);
qrCodeMap.put(new Integer(i + 1), qrCodeResult);
 }

Now my qrCodeMap has Integer and Result[] array object

I add this map object to model in my Spring Controller :

model.addAttribute("qrCodeMap", qrCodeMap);

I want to display qrCodeMap in jsp using jstl. Could you please tell me how I should iterate through qrCodeMap (ie. a Map) in jsp? Below is my incomplete code:

<c:forEach var="qrCode" items="${qrCodeMap}">
For Page ${qrCode.key} , QR Codes : 
<c:forEach items="${qrCode.value}" var="item">
</c:forEach>
</c:forEach> 

If it is easier to do through scriplets, then kindly suggest the syntax. Thanks in advance.

1 Answer 1

0
<c:forEach var="qrCode" items="${qrCodeMap}">
    For Page: ${qrCode.key} , QR Codes :<br/>
    <c:forEach var="result" items="${qrCode.value}">
        ${result.attr}<br/>
    </c:forEach>
</c:forEach>

Where attr is the attribute you want to show from Result.

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

3 Comments

Thank you very much @Sedooe. Also, thank you to Stackoverflow for such wonderful website. Success is never achieved alone. There is always someone who helps you. Best Regards.
Thank you, I did not knew that.

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.