Java 在jsp中遍历嵌套的哈希映射

Java 在jsp中遍历嵌套的哈希映射,java,jsp,hashmap,nested,jstl,Java,Jsp,Hashmap,Nested,Jstl,我已经写了一个像这样的嵌套hashmap HashMap<String, String> choice_map = new HashMap<String, String> (); choice_map.put("4","<?php ?>"); choice_map.put("2","<? ?>"); choice_map.put("1","<? >"); choice_map.put("3","

我已经写了一个像这样的嵌套hashmap

    HashMap<String, String> choice_map = new HashMap<String, String> ();

    choice_map.put("4","<?php ?>");
    choice_map.put("2","<? ?>");
    choice_map.put("1","<? >");
    choice_map.put("3","< ?>");

    HashMap<String, String> que_id_map = new HashMap<String, String> ();

    que_id_map.put("1",null);

    HashMap<String, String> que_type_map = new HashMap<String, String> ();

    que_type_map.put("Objective",null);

    HashMap<String, String> que_map = new HashMap<String, String> ();

    que_map.put("What is Short Tag in PHP?",null);

    HashMap<String, HashMap<String, String>> main_choice_map = new HashMap<String, HashMap<String, String>>();


    main_choice_map.put("question",que_map);
    main_choice_map.put("question_type_id",que_id_map);
    main_choice_map.put("question_type",que_type_map);
    main_choice_map.put("choices",choice_map);

   HashMap<String, HashMap<String, HashMap<String, String>>> questions_with_choices = new HashMap<String, HashMap<String, HashMap<String, String>>> ();

   questions_with_choices.put("2",main_choice_map);
上述hashmap问题与选项的输出如下所示:

{2={question_type_id={1=null},question_type={Objective=null},choices={3=<?>,2=,1=},question={PHP中的短标记是什么?=null}}

如何在jsp或jstl中迭代此hashmap


请帮助我..

您知道如何在Java中迭代hashmap吗?这在JSP中是类似的——您只需要用scriptlet标记包围代码即可。@kwikness感谢Luiggi;我很清楚JSP很糟糕,但OP要求用JSP或JSTL提供解决方案。谢谢你的回答。。请给我的hashmap的完整代码。。。我会接受你的回答
<%
Iterator it = mp.entrySet().iterator();
while (it.hasNext()) {
    Map.Entry pairs = (Map.Entry)it.next();
%>
    <h1><%=pairs.getKey()%> = <%=pairs.getValue()%></h1>
<%
    it.remove(); // avoids a ConcurrentModificationException
}
%>