<%@page import="java.util.*"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body>
<%
List<Map<String,String>> list = new ArrayList<Map<String,String>>();
Map<String,String> map = new HashMap<String,String>();
map.put("name", "つかだ");
map.put("ads", "東京");
map.put("phone", "080-1111-1111");
list.add(map);
map = new HashMap<String,String>();
map.put("name", "たかはし");
map.put("ads", "千葉");
map.put("phone", "080-1111-2222");
list.add(map);
map = new HashMap<String,String>();
map.put("name", "TTT");
map.put("ads", "東京");
map.put("phone", "080-1111-3333");
list.add(map);
request.setAttribute("list", list); String[][] ary_2 = new String[3][3];
ary_2[0][0] = "つかだ";
ary_2[0][1] = "東京";
ary_2[0][2] = "080-1111-1111";
ary_2[1][0] = "たかはし";
ary_2[1][1] = "千葉";
ary_2[1][2] = "080-1111-2222";
ary_2[2][0] = "TTT";
ary_2[2][1] = "東京";
ary_2[2][2] = "080-1111-3333";
request.setAttribute("ary_2", ary_2); String info = "つかだ,東京,080-1111-1111;たかはし,千葉,080-1111-2222;TTT,東京,080-1111-3333;";
request.setAttribute("info", info);
%>
<table border="1">
<tr>
<th>名前</th>
<th>住所</th>
<th>電話NO</th>
</tr>
<c:forEach items="${ list }" var="map">
<tr>
<td>${ map.name }</td>
<td>${ map.ads }</td>
<td>${ map.phone }</td>
</tr>
</c:forEach>
</table>
<br/>
<table border="1">
<tr>
<th>名前</th>
<th>住所</th>
<th>電話NO</th>
</tr>
<c:forEach items="${ ary_2 }" var="ary" varStatus="s">
<tr>
<td>${ ary[0] }</td>
<td>${ ary[1] }</td>
<td>${ ary[2] }</td>
</tr>
</c:forEach>
</table>
<br/>
<table border="1">
<tr>
<th>名前</th>
<th>住所</th>
<th>電話NO</th>
</tr>
<c:forTokens items="${ info }" var="one" delims=";" >
<tr>
<c:forTokens items="${ one }" var="v" delims="," >
<td>${ v }</td>
</c:forTokens>
</tr>
</c:forTokens>
</table>
</body>
</html>

JSP中forEach和forTokens循环的用法的更多相关文章

  1. jsp中的JSTL与EL表达式用法

    JSTL (JSP Standard Tag Library ,JSP标准标签库) JSTL标签库分为5类:JSTL核心标签库.JSTL函数标签库.数据库标签库.I18N格式化标签库.XML标签库. ...

  2. 【转】JSP中的JSTL与EL表达式用法及区别

    对于JSTL和EL之间的关系,这个问题对于初学JSP的朋友来说,估计是个问题,下面来详细介绍一下JSTL和EL表达式他们之间的关系,以及JSTL和EL一些相关概念! EL相关概念JSTL一般要配合EL ...

  3. jsp中的JSTL与EL表达式用法及区别

    对于JSTL和EL之间的关系,这个问题对于初学JSP的朋友来说,估计是个问题,下面来详细介绍一下JSTL和EL表达式他们之间的关系,以及JSTL和EL一些相关概念! EL相关概念 JSTL一般要配合E ...

  4. JSP中的include的两种用法

    1.两种用法 <%@ include file=” ”%> <jsp:include page=” ” flush=”true”/> 2.用法区别 (1)执行时间上区别 < ...

  5. mybatis 中 foreach collection的三种用法

    foreach的主要用在构建in条件中,它可以在SQL语句中进行迭代一个集合. foreach元素的属性主要有 item,index,collection,open,separator,close. ...

  6. mybatis 中 foreach collection的三种用法(转)

    文章转自 https://blog.csdn.net/qq_24084925/article/details/53790287 oreach的主要用在构建in条件中,它可以在SQL语句中进行迭代一个集 ...

  7. Mybatis 中 foreach collection 的三种用法

    foreach的主要用在构建in条件中,它可以在SQL语句中进行迭代一个集合. foreach元素的属性主要有 item,index,collection,open,separator,close. ...

  8. mybatis中foreach collection的三种用法

    foreach的主要用在构建in条件中,它可以在SQL语句中进行迭代一个集合. foreach元素的属性主要有 item,index,collection,open,separator,close. ...

  9. jsp中for-each应用(遍历数据相乘再相加)

随机推荐

  1. 面试题-----求单链表的倒数第k个节点

    #include <iostream> using namespace std; struct node{ int value; struct node *next; }; struct ...

  2. 修改ASP.NET文件上传大小限制

    转自:http://www.hello-code.com/blog/asp.net/201603/5954.html 要点: 1.web.config中的<httpRuntime maxRequ ...

  3. Redis运行流程源码解析--转载

    http://blog.nosqlfan.com/html/4007.html http://www.searchdatabase.com.cn/showcontent_62166.htm 导读:本文 ...

  4. 用PDMReader工具生成数据库设计文档(转载)

    来源:http://blog.csdn.net/xinglun88/article/details/19987719 第一步:下载并安装PDMReader,资源网站: http://www.pdmre ...

  5. synchronized实现可见性

    JMM关于synchronized的两条规定: 1)线程解锁前,必须把共享变量的最新值刷新到主内存中 2)线程加锁时,将清空工作内存中共享变量的值,从而使用共享变量时需要从主内存中重新获取最新的值 ( ...

  6. ssh连接工具中文乱码问题

    在终端运行: export LC_ALL=zh_CN.GB2312;export LANG=zh_CN.GB2312

  7. Oracle11g密码过期处理方法

    首先 查询密码有效期:   SELECT * FROM dba_profiles s WHERE s.profile='DEFAULT' AND resource_name='PASSWORD_LIF ...

  8. 发起qq临时会话

    http://wpa.qq.com/msgrd?v=3&uin=947739614&site=qq&menu=yes

  9. [日常] 研究redis未授权访问漏洞利用过程

    前提:redis允许远程连接,不需要密码 1522057495.583846 [0 123.206.24.121:50084] "set" "dUHkp" &q ...

  10. NSLayoutConstraint 遍历查找对应的约束

      当我们使用纯代码方式Autolayout进行布局约束时,一个view上可能添加了很多的约束.而这些约束又不像view一样有一个可以区分的tag值,茫茫约束中想查到想要的约束然后进行更改,好像很难. ...