java - Iterating over hashmap in JSP in struts application -


I have a hashmap object which I'm getting on a JSP page.

  HashMap & LT; Integer, gift_product & gt; Gift_hm = New Hashmop & lt; Integer, gift_product & gt; (); Gift_hm.put (17, new gift_product ("doll", 67));  

Now I have to repeat it and display the content on JSP. There are two fields in the Gift_product category: names and values ​​.

JSP should be output

  serial number product name Price 17 Doll 67 67 How do I get it?   

View the Strates Tag When running on a Hashmap, each entry is a java.util.Map key and value to get the key (Gift_product object) and the value (Gift_product object) in this example: / P>

First set the Hashket as a feature in your action class request.setAttribute ("gift_hm", gift_hum); and then jsp:

  & lt; Logic: iterate id = "mapEntry" name = "gift_hm" and gt; & Lt; Bean: defined id = "gift" name = "map entry" property = "value" & gt; & Lt; TR & gt; & Lt; Td> Bean: Write name = "mapinternal" property = "key" & gt; & Lt; / Td> & Lt; Td> Bean: writing name = "gift" property = "product name" & gt; & Lt; / Td> & Lt; Td> Bean: write name = "gift" property = "value" & gt; & Lt; / Td> & Lt; / TR & gt; & Lt; / Logic: recurrence & gt;  

Comments

Popular posts from this blog

windows - Heroku throws SQLITE3 Read only exception -

lex - Building a lexical Analyzer in Java -

python - rename keys in a dictionary -