在action 使用request.setAttribute
set一个map 在jsp页面能不能用c标签 取得键对应的值?
类似于 map.get(key) 的实现。
set一个map 在jsp页面能不能用c标签 取得键对应的值?
类似于 map.get(key) 的实现。
解决方案 »
- ----struts版本----
- 淘宝商品发布的HTML编辑器
- struts2一个错误,求高手解决
- js新手请教:动态下拉列表的问题
- 帮我推荐一本servlet的书
- 高分求在线电影播放系统程序300分
- 请问 java.sql.Blob 和oracle.sql.BLOB使用上 有什么区别?
- 突然发现用绝对地址<%@ include file="D:\\123\\pubuse.jsp" %>不行?
- 请问如何可实现“在一个连接上单击时,就会出现windows的那个下载文件的框,即相当于右键另存为的那个”?
- 结果集可以嵌套吗?
- 求ext js 的模式窗口!急!急!!!
- 三年J2EE工作经验,面试时死在了正则表达式上
这样是取到了,可我map里面的值时list 怎么遍历这个list
求解
Map child = new HashMap();
for (Iterator iterator = list.iterator(); iterator.hasNext();) {
CrmModule c = (CrmModule) iterator.next();
child.put((String)c.getCrmModuleId(), new CrmModuleAjaxAction()
.twoLevelModuleList(c.getCrmModuleId()));
}
request.setAttribute("list", list);
request.setAttribute("child", child);
return mapping.findForward("index");jsp页面先遍历list
map的key是 list里面bean的属性
现在的问题是 怎么通过key 找到map里面对应的list 赋给某个变量或者怎么遍历list
<c:forEach items="${list}" var="list" >
<c:forEach items="${child}" var="map">
<c:if test="${map.key} eq ${list.crmModuleId}">
<c:out value="${map.key}" />
<c:forEach items="${map.value}" var="childList">
${childList.crmModuleName}
</c:forEach>
</c:if>
</c:forEach>
</c:forEach>
这个方法有错吗?为什么我页面没输出
试一下这个:<c:if test="${map.key eq list.crmModuleId"> <c:forEach items="${list}" var="list" >
<c:forEach items="${child}" var="map">
<c:if test="${map.key eq list.crmModuleId"> <!--这样写试一下-->
<c:out value="${map.key}" />
<c:forEach items="${map.value}" var="childList">
${childList.crmModuleName}
</c:forEach>
</c:if>
</c:forEach>
</c:forEach>
<c:forEach items="${list.mapValue}" var="map">
<c:if test="${map[\"key\]!=null}">
${map[\"key\]
</c:if>
</c:forEach>
</c:forEach>
<c:forEach items="${child}" var="map">
<c:if test="${fn:containsIgnoreCase(fn:trim(map.key),fn:trim(list.crmModuleId))}" var="flag">
<c:forEach items="${map.value}" var="childList">
</c:forEach>
</c:if>
</c:forEach>
</c:forEach>
<c:forEach items="${child}" var="map">
<c:if test="${map.key eq list.crmModuleId}">
<c:out value="${map.key}" />
<c:forEach items="${map.value}" var="childList">
${childList.crmModuleName}
</c:forEach>
</c:if>
</c:forEach>
</c:forEach>