EL表达式遍历集合获取下标
如题,HTML页面很多时候需要循环遍历一个集合,并且获得集合元素得下标做判断,或者把下标传递给后台作为参数
那么我们就需要用到EL表达式的varStatus
代码一:
<c:forEach var="news" items="${newlist}" varStatus="index">
<p><a class="newInfo" href="${pageContext.request.contextPath}/static/toNewView/${index.index}/${news.nId}">${news.title}...</a></p>
</c:forEach> 代码二:
<c:forEach var="card" items="${browseList}" varStatus="indexo">
<ul>
<li class="shopping_commend_list_1">·<a href="${pageContext.request.contextPath}/static/toCardView/${card.cId}/${card.gid}" class="blue">${card.cName}</a></li>
<li class="shopping_commend_list_2">¥${card.iniPrice}</li>
<li class="shopping_commend_list_3">¥${card.price}</li>
<li class="shopping_commend_list_4"><a href="#" class="shopping_yellow">购买</a></li>
<li class="shopping_commend_list_5" style="display: none">${card.titleImg}</li>
<li class="shopping_commend_list_6" style="display: none">${card.gName}</li>
<li class="shopping_commend_list_7" style="display: none">${card.cName}</li>
<li class="shopping_commend_list_8" style="display: none">${card.cId}</li>
<li class="shopping_commend_list_9" style="display: none">${card.gid}</li>
</ul>
<c:if test="${indexo.count/1==5}">
</div>
<div class="shopping_commend_sort_mid"></div>
<div class="shopping_commend_sort_left">
</c:if>
<c:if test="${indexo.last}">
</div>
</div>
</c:if>
</c:forEach>
综上总结:使用varStatus.index 和varStatus.count都可以获得相应得下标值。
EL表达式遍历集合获取下标的更多相关文章
- JSP第四篇【EL表达式介绍、获取各类数据、11个内置对象、执行运算、回显数据、自定义函数、fn方法库】
什么是EL表达式? 表达式语言(Expression Language,EL),EL表达式是用"${}"括起来的脚本,用来更方便的读取对象! EL表达式主要用来读取数据,进行内容的 ...
- el 表达式遍历Map
el 表达式遍历Map<c:forEach var="item" items="${payMentMap}"> <option value=& ...
- Lambda表达式遍历集合
1.Collection Java 8 为Iterable接口新增了一个forEach(Consumer action)默认方法,该方法所需参数的类型是一个函数式接口,而Iterable接口是Coll ...
- JS中使用EL表达式方法与获取工程名字
关键: 在js中使用el表达式一定要使用双引号 分两种情况 1. JS代码在JSP页面中, 这可以直接使用EL表达式. 如: <script type="text/javas ...
- Lambda 表达式遍历集合时用remove方法删除list集合中满足条件的元素问题
一:循环遍历list集合的四种方式 简单for循环 iterator循环 增加for循环 Lanbda表达式 二:四种遍历方式的用法示例 //简单for循环 List<SalaryAdjustm ...
- struts框架值栈问题七之EL表达式也会获取到值栈中的数据
7. 问题七:为什么EL也能访问值栈中的数据? * StrutsPreparedAndExecuteFilter的doFilter代码中 request = prepare.wrapRequest(r ...
- EL表达式遍历Map集合
<% Map<String,String> map2 = new HashMap(); map2.put("a","hello world") ...
- javascript中遍历EL表达式List集合中的值
http://www.cnblogs.com/limeiky/p/6002900.html
- 运用El表达式截取字符串/获取list的长度
${fn:substring(wjcd.lrsj, 0, 16)} 使用functions函数来获取list的长度 ${fn:length(list)} 引入 <%@ taglib prefix ...
随机推荐
- Flask 构建微电影视频网站(一)
Flask构建电影视频网站 Python MTV模型 Flask微内核 Flask扩展插件配置及使用方法 根据业务开发网站前后台功能 Flask结合MySQL数据库 你将可以独立开发网站 独立部署运维 ...
- 「中国剩余定理CRT」学习笔记
设正整数$m_1, m_2, ... , m_r$两两互素,对于同余方程组 $x ≡ a_1 \ (mod \ m_1)$ $x ≡ a_2 \ (mod \ m_2)$ $...$ $x ≡ a_r ...
- Matplotlib学习---用matplotlib画面积图(area chart)
这里利用Nathan Yau所著的<鲜活的数据:数据可视化指南>一书中的数据,学习画图. 数据地址:http://book.flowingdata.com/ch05/data/us-pop ...
- 【XSY2731】Div 数论 杜教筛 莫比乌斯反演
题目大意 定义复数\(a+bi\)为整数\(k\)的约数,当且仅当\(a\)和\(b\)为整数且存在整数\(c\)和\(d\)满足\((a+bi)(c+di)=k\). 定义复数\(a+bi\)的实部 ...
- Java实现月份递减
问题:从当前月份开始,往前3年的所有月份 返回map类型,key是String,value是Date,map倒序排列 public static Map<String, Date> get ...
- Github Desktop 克隆新项目 Authentication failed. You may not have permission to access the repository or the repository may ha
原来:ssh://git@github.com/xxx.git 改成:https://git@github.com/xxx.git
- MT【258】椭圆第三定义
如图,已知椭圆方程为$\dfrac{x^2}{4}+\dfrac{y^2}{3}=1$$A$为椭圆上一点,$AF_1,AF_2$与椭圆交于$B,C$两点,$A_1B,A_2C$交于一点$M$.当$A$ ...
- Pycharm自动添加文件头注释
1.选择File -> Settings 2.选择 File and Code Templates -> Files -> Python Script 3.设置 #!/usr/bin ...
- webpack入门(三)webpack的api
终于到了webpack api这一篇,我都等不及了0.0; webpack is fed a configuration object. Depending on your usage of webp ...
- zabbix监控URL
选在相应主机,并添加Web监控 按照方式新建Web场景 注意: 名称统一规则:web_check_相应的域名 应用集:新建一个,名称为“web状态” 更新间隔:改为30s,默认为1m 尝试次数:改为2 ...