I have HasMap object like this:
HashMap<String,String> fileCounter = new HashMap<String,String>();
fileCounter.put("Total Files","15");
fileCounter.put("Total Success Files","10");
fileCounter.put("Total Failed Files","2");
fileCounter.put("Total In Process Files","4");
fileCounter.put("Total Records","100");
fileCounter.put("Total Success Records","80");
fileCounter.put("Total Failed Records","10");
fileCounter.put("Total In Process Records","10");
my iterator logic is this:
<logic:iterate id="mapEntry" name="fileCounter">
<tr>
<td><bean:write name="mapEntry" property="key"></td>
<td><bean:write name="mapEntry" property="value"></td>
</tr>
</logic:iterate>
Problem:
when i perform iteration, map values and keys are shuffled,So all itema are in not printed as given in java code.
can any one help me, How to print this map in as it is in given sequence.
I want output like this:
Total Files 15
Total Success Files 10
Total Failed Files 2
Total In Process Files 4
Total Records 10
Total Success Records 80
Total Failed Records 10
Total In Process Records 10
Use a LinkedHashMap instead of a regular HashMap. It iterates in the order that items were inserted.