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页面遍历可以 获得这个对象
??
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页面遍历可以 获得这个对象
??
解决方案 »
- 我的程序总是报java.lang.NumberFormatException: null,大家能帮我看看吗?谢谢!
- 求助:在用MYECLIPSE创建数据表的ORM文件时报错,贴出报错信息,以及相关配置文件信息,谢谢大家给予指正
- SqlServer2000中的DateTime类型如何转换为Java中的Date类型 在线等候!!!
- 请问用JSP+ORACLE数据库写的论坛有地方上传吗????
- 怎么写一个类,让他每过5分钟调用另外一个方法?
- 哪位哥哥能帮忙?
- 关于JAVA和javascript交互的问题
- 在线等,求救。好心人请进
- 为什么一样的程序在写到JSP里就不能运行了???
- 怎样将XML文件中的数据直接映射到数据库的例子?
- ssh2增加的诡异问题,求助(内详)
- 请教:javaweb服务端处理跨站脚本方案
map.put("threadsList", threadsList);
---------------------------------------------------------
Threads threads = map.get("threads");
Object threadsList = map.get("threadsList");
map.get(i) //此处获得的就是对象
}
-----------------------------------------------------------------
request.getSession().getAttribute("threadsList");
===========================
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");
}
Map<String,List> map=new HashMap<String,List>();这样来组合了
然后再根据key ,value 来循环取就行了