当前位置:网站首页>Jsp uses to traverse the List collection "recommended collection"
Jsp uses to traverse the List collection "recommended collection"
2022-07-29 23:17:00 【Full stack programmer webmaster】
Hello everyone, we meet again, I'm your friend Quanstack Jun.
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%><%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %><%String path = request.getContextPath();String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";%><%List list = new ArrayList();list.add("Simple is a prerequisite for reliability");list.add("Interest is the best teacher");list.add("Investment in knowledge always gets the best return");request.setAttribute("list", list);%>Jsp uses c:forEach to traverse the List collection Traverse all elements of the List collection:
${id.index} ${keyword}
Traverse the elements after the first element in the List collection (excluding the first element):
${id.index} ${keyword}
Two layers of List traversal
<%List list = new ArrayList();List list1 = new ArrayList();List list2 = new ArrayList();list1.add("1-a");list1.add("1-b");list2.add("2-d");list2.add("2-c");list.add(list1);list.add(list2);request.setAttribute("list1", list1);request.setAttribute("list", list);%>${item2 } Publisher: Full-stack programmer, please indicate the source: https://javaforall.cn/129762.htmlOriginal link: https://javaforall.cn
边栏推荐
猜你喜欢
随机推荐
[leetcode] 82. Delete duplicate elements in sorted linked list II (medium)
真offer收割机 第一弹~大厂如何考察候选人?(附答案详解)
重写并自定义依赖的原生的Bean方法
Jsp使用&lt;c:forEach&gt;遍历List集合「建议收藏」
流水线上的农民:我在工厂种蔬菜
推荐 7 个学习 Web3 的开源资源
【leetcode】剑指 Offer II 002. 二进制加法
地狱挖掘者系列#1
cv.copyMakeBorder(imwrite opencv)
ah?Now the primary test recruitment requirements will be automated?
趣味隐写术与密码术(现代密码学教程)
【面试:并发篇34:Unsafe】
pnpm + workspace + changesets 构建你的 monorepo 工程
DNA修饰纳米金颗粒|DNA脱氧核糖核酸偶联修饰碳纳米材料|实验原理
WY16 不要二
嵌入式系统驱动初级【1】——内核模块上_编译方法
文档贡献与写作必读-OpenHarmony开发者文档风格指南
【MySQL系列】 MySQL表的增删改查(进阶)
Access the company intranet
你真的了解Redis的持久化机制吗?









