【发布时间】:2014-09-17 19:42:22
【问题描述】:
我已经写了一个这样的嵌套哈希图......
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(questions_with_choices)的输出是这样的:
{2={question_type_id={1=null}, question_type={Objective=null}, 选择={3=>, 2= ?>, 1= >, 4=}, question={什么是 PHP 中的短标签?=null}}}
如何在jsp或jstl中遍历这个hashmap?
请帮帮我..
【问题讨论】:
-
你知道如何在 Java 中遍历 hashmap 吗?这在 JSP 中是类似的——你只需用 scriptlet 标签包围代码。
-
@kwikness How to avoid Java Code in JSP-Files?
-
谢谢路易吉;我很清楚 JSP 很烂,但 OP 要求在 JSP 或 JSTL 中提供解决方案。
标签: java jsp hashmap nested jstl