El表达式取不到session中确实有的Map 下面代码没有效果 求大神解答
<c:forEachitems="${sessionScope.workerMap['1']}"var="workers"><%inti=1;%><tr><tdclass...
<c:forEach items="${sessionScope.workerMap['1']}" var="workers">
<%
int i=1;
%>
<tr>
<td class=tablebody2 valign=middle align=center width=""><%=i++ %></td>
<td class=tablebody1 valign=middle width=""> ${workers.Id }</td>
<td class=tablebody2 valign=middle align=left width=""> ${workers.Name }</td>
<td class=tablebody1 valign=middle align=center width="">${workers.Dept }</td>
<td class=tablebody2 valign=middle align=left width=""> ${workers.Position } </td>
</tr>
</c:forEach>
servlet中是这样写的:HttpSession session = request.getSession();
ServletContext sc = request.getServletContext();
WorkServiceImpl service = new WorkServiceImpl();
workers = (Map<Integer, Worker>) sc.getAttribute("workers");
session.setAttribute("workerMap", workers);
Map maps = (Map) session.getAttribute("workerMap");
System.out.println(maps.get(1));
Worker wor = (Worker) maps.get(1);
System.out.println(wor.getId());
response.sendRedirect("renshi/message.jsp");
下边的输出语句都是能成功得到值的 展开
<%
int i=1;
%>
<tr>
<td class=tablebody2 valign=middle align=center width=""><%=i++ %></td>
<td class=tablebody1 valign=middle width=""> ${workers.Id }</td>
<td class=tablebody2 valign=middle align=left width=""> ${workers.Name }</td>
<td class=tablebody1 valign=middle align=center width="">${workers.Dept }</td>
<td class=tablebody2 valign=middle align=left width=""> ${workers.Position } </td>
</tr>
</c:forEach>
servlet中是这样写的:HttpSession session = request.getSession();
ServletContext sc = request.getServletContext();
WorkServiceImpl service = new WorkServiceImpl();
workers = (Map<Integer, Worker>) sc.getAttribute("workers");
session.setAttribute("workerMap", workers);
Map maps = (Map) session.getAttribute("workerMap");
System.out.println(maps.get(1));
Worker wor = (Worker) maps.get(1);
System.out.println(wor.getId());
response.sendRedirect("renshi/message.jsp");
下边的输出语句都是能成功得到值的 展开
1个回答
2015-01-01
展开全部
map不是用数组取的,是用key取出value
追问
我的key就是String类型的1.用
无信息!
其它
检测到里边是有东西的 就是打不到页面上。。。谢谢
追答
有东西,肯定不正确,循环是用keyset()方法
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询