Map map=new HashMap();
for(int i=0;i<list.size();i++)

Polls polloptions=(Polls)list.get(i);
System.out.println("是投票主题的id有"+polloptions.getTid());
Threads threads = (Threads)poll.findPostsByid(polloptions.getTid());
threadsList =poll.findFourm(threads.getFid());
 if(threadsList!=null)
   {
      map.put("threads", threads);
 map.put("threadsList", threadsList);
  System.out.println(map);
   }
request.getSession().setAttribute("threadsList", threadsList);
}
Iterator<String> it=map.keySet().iterator();
  while(it.hasNext()){
 it.hashCode();;
    System.out.println(it.next());
// Object key =  entry.getStyleid();
//     Object val = entry.getName();
} 控制台语句是投票主题的id有38
 from Threads as p where   p.tid =38
from  Forums where fid =9
{threads=cn.jsprun.domain.Threads@1364ee5, threadsList=[cn.jsprun.domain.Forums@17a7adf]}
threads
threadsList
 我Map里面存进去的是一个  threads对象 和   threadsList 集合 我想请问如何在  JAVA里面 遍历的时候获得对象  或者在jsp页面遍历可以 获得这个对象 
 ??
  

解决方案 »

  1.   

    map.put("threads", threads);
    map.put("threadsList", threadsList);
    ---------------------------------------------------------
    Threads threads = map.get("threads");
    Object threadsList = map.get("threadsList");
      

  2.   

    for(int i=0;i<map.size();i++){
    map.get(i) //此处获得的就是对象
    }
      

  3.   

    request.getSession().setAttribute("threadsList", threadsList);
    -----------------------------------------------------------------
    request.getSession().getAttribute("threadsList");
      

  4.   

    threadsList =poll.findFourm(threads.getFid());这个放在循环里面被覆盖了.MAp里面存储的 Threads对象也被覆盖了 有解决方案么?
                
      

  5.   

    不知道你要做什么,如果你需要每一个poll相关的,threads及threadsList放到jsp中,那参考下面的代码
     ===========================       
            List<Map> lists = new ArrayList<Map>();
            for(int i=0;i<list.size();i++)
            { 
                Polls polloptions=(Polls)list.get(i);
                System.out.println("是投票主题的id有"+polloptions.getTid());
                Threads threads = (Threads)poll.findPostsByid(polloptions.getTid());
                threadsList =poll.findFourm(threads.getFid());
                 if(threadsList!=null)
                   {
                     Map map=new HashMap();
                     map.put("threads", threads);
                     map.put("threadsList", threadsList);
                         System.out.println(map);
                   }
                //request.getSession().setAttribute("threadsList", threadsList);
                lists.add(map);
            }
            request.getSession().setAttribute("lists", lists);
    ---------------------------------------------------------------
    List<Map> lists = request.getSession().getAttribute("lists");
    for(int i...){
      Map m = lists[i];
      Threads threads = m.get("threads");
       Object threadsList = m.get("threadsList"); 
    }
      

  6.   

    LZ那的意思好象是对象与LIST是对应关系的:
    Map<String,List> map=new HashMap<String,List>();这样来组合了
    然后再根据key ,value 来循环取就行了