Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/jsp/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Hibernate 如何迭代映射<;字符串,列表>;map=新HashMap<;字符串,列表>;()在使用JSTL的jsp页面中_Hibernate_Jsp_Spring Mvc_Hashmap_Jstl - Fatal编程技术网

Hibernate 如何迭代映射<;字符串,列表>;map=新HashMap<;字符串,列表>;()在使用JSTL的jsp页面中

Hibernate 如何迭代映射<;字符串,列表>;map=新HashMap<;字符串,列表>;()在使用JSTL的jsp页面中,hibernate,jsp,spring-mvc,hashmap,jstl,Hibernate,Jsp,Spring Mvc,Hashmap,Jstl,我将两个列表添加到一个Map Map=newhashmap()。我希望使用JSTL在jsp页面中从中获取值 我的发明者是 @RequestMapping("/addprogram") public ModelAndView thematicday() { Map<String, List> map = new HashMap<String, List>(); try{ List<Themes> theme

我将两个列表添加到一个Map Map=newhashmap()。我希望使用JSTL在jsp页面中从中获取值 我的发明者是

     @RequestMapping("/addprogram")
 public ModelAndView thematicday()

  {
     Map<String, List> map = new HashMap<String, List>(); 
     try{
        List<Themes> theme=dataServices.getTheme();
        List<String> themeday=dataServices.getThematicDate();

         map.put("theme", theme);
         map.put("themeday", themeday);
    }
    catch(Exception e)
    {
        e.printStackTrace();
    }
     return new ModelAndView("thematicday","map",map);
  }
请试试这个

<c:forEach var="themedays" items="${map.themeday}">
     <c:foreach var="theme" items="${themedays}">
       <b> ${theme} </b>
    </c:foreach>
</c:foreach>

${theme}

下面的方法可用于使用字符串和bean对象列表迭代hashmap

<c:forEach items="${map}" var="events">
 // iterate the key here
    StringValues= ${events.key} 
 // iterate the values of list here
    <c:forEach items="${events.value}" var="item" >
        ${item} 
    </c:forEach>
 </c:forEach>

//在这里迭代键
StringValues=${events.key}
//在此处迭代列表的值
${item}
请参见此处:


很抱歉,我得到了“主题日”的结果。实际上我需要得到结果2015年1月14日第1007天2015年2月14日第1008天获取值[Ljava.lang.Object;@a3e5fc[Ljava.lang.Object;@502bb9.不是精确的值。@PriyankaShaju刚刚观察到,你正在做
Object.toString()
,你得到的是什么对象,你调试过了吗,你看到你的列表了吗。你正在添加
Object.toString()
进入您的
列表
,问题就在这里,请更正此问题。您可能需要调用getter on result或类似的
result.get(“主题”)
,然后添加到
列表
,但我不能使用List result=(List)query.List();而不是List result=(List)query.List();。当我使用此列表result=(List)时query.list();for(ThematicDay p:result){System.out.println(“*********************”+p.getThemedate());}它显示错误“java.lang.ClassCastException:[Ljava.lang.Object;无法转换为com.astra.model.ThematicDay”;它还打印列表的值,这里是[Ljava.lang.Object;@1a99a72[Ljava.lang.Object;@1dadad3.实际上我需要得到2015年1月14日第100天2015年2月14日的结果DAY107@Priyanka似乎您没有正确访问bean属性,您能用您现在正在尝试的代码更新您的问题吗?但是我不能使用List result=(List)query.List()而不是List result=(List)query.List()。请您解释一下如何在我的DaoImpl中存储列表中的值。您需要观察所获得的
列表
,在填充
列表
时使用一个数据,不要使用
对象。toString()
,迭代
列表
,获取
主题的值
,并填充
列表
<c:forEach var="Date" items="${map}">
                     <c:if test="${Date.key == 'themeday'}">
                    <div class="bottom-article">
                        <ul class="meta-post">
                            <li><a href="#" class="tl_1"> ${Date.value[0]} </a></li>
                            <li><a href="#" class="tl_2">${Date.value[1]} </a></li>
                        </ul>
                        </div>
                        </c:if>
                        </c:forEach>
[Ljava.lang.Object;@762b0f
[Ljava.lang.Object;@4f983
<c:forEach var="themedays" items="${map.themeday}">
     <c:foreach var="theme" items="${themedays}">
       <b> ${theme} </b>
    </c:foreach>
</c:foreach>
<c:forEach items="${map}" var="events">
 // iterate the key here
    StringValues= ${events.key} 
 // iterate the values of list here
    <c:forEach items="${events.value}" var="item" >
        ${item} 
    </c:forEach>
 </c:forEach>