首页
论坛
图书
开发资料
在线文档
网址
下载
联系我们
 新闻│Java│JavaScript│Eclipse│Eclipse 英文│J2EE│J2ME│J2SE│JSP│Netbeans│Hibernate│JBuilder│Spring│Struts
站内搜索: 请输入搜索关键词

当前页面: 开发资料首页 → Java 专题 → jstl之foreach循环

jstl之foreach循环

摘要: jstl之foreach循环

</td> </tr> <tr> <td height="35" valign="top" class="ArticleTeitle"> <table width="665" border="0"> <tr> <td width="388">
<%@ page contentType="text/html; charset=GBK" %>
<%@ page import="java.util.*" %>

<%@ taglib uri="http://java.sun.com/jstl/core" prefix="c" %>

<head>
JSTL测试1--c:forEach循环
</head>

<body>
一、整数

,

</td> <td width="267"> </td> </tr> </table>

二、计算x的平方
<table>
<tr><th>Value</th>
<th>Square</th></tr>

<tr><td></td>
<td></td></tr>

</table>


三、字符串"47,52,53,55,46,22,16,2" 分隔.
<table border="1">

<tr><td></td></tr>

</table>


四、使用步长
<table>
<tr><th>second</th>
<th>second</th></tr>

<tr><td></td>
<td></td></tr>

</table>


五、对数组进行循环


<% int ai[] = {10, 20, 30, 40, 50};
pageContext.setAttribute("ary", ai);
%>

*



<%
Cookie c=new Cookie("cookie1","one");
response.addCookie(c);
%>

<%
Cookie cookies[]=request.getCookies();
Cookie sCookie=null;
String sname=null;
String name=null;
if(cookies==null) // 如果没有任何cookie
out.print("none any cookie");
else
{
//out.print(cookies.length + "
");
for(int i=0;i {
sCookie=cookies[i];
sname=sCookie.getName();
name = sCookie.getValue();
out.println(sname + "->" + name + "
");
}
}
%>

<table border="1" align="center">
<tr><th>Cookie Name</th>
<th>Cookie Value</th></tr>

<tr><td></td>
<td></td></tr>

</table>



六、字符串数组循环
<% String as[] = {
"A first string", "La deuxieme string", "Ella troisiemo stringo"
};
request.setAttribute("stringArray", as);
%>






七、枚举
<%
Hashtable hashtable1 = new Hashtable();
pageContext.setAttribute("numberMap", hashtable1);

hashtable1.put(new Integer(1), "uno");
hashtable1.put(new Integer(2), "dos");
hashtable1.put(new Integer(3), "tres");
hashtable1.put(new Integer(4), "cuatro");
hashtable1.put(new Integer(5), "cinco");
hashtable1.put(new Integer(6), "seis");
hashtable1.put(new Integer(7), "siete");
hashtable1.put(new Integer(8), "ocho");
hashtable1.put(new Integer(9), "nueve");
hashtable1.put(new Integer(10), "diez");

java.util.Enumeration enumeration = hashtable1.keys();
pageContext.setAttribute("enumeration", enumeration);
%>





八、map



=





</body>

function TempSave(ElementID) { CommentsPersistDiv.setAttribute("CommentContent",document.getElementById(ElementID).value); CommentsPersistDiv.save("CommentXMLStore"); } function Restore(ElementID) { CommentsPersistDiv.load("CommentXMLStore"); document.getElementById(ElementID).value=CommentsPersistDiv.getAttribute("CommentContent"); } </td> </tr> <tr>


↑返回目录
前一篇: 使用EL、JSTL处理表单数据
后一篇: Lucene倒排索引原理

首页 | 全站 Sitemap | 联系我们 | 设为首页 | 收藏本站
版权所有 Copyright © 2006-2007, Java 编程资料牛鼻站, All rights reserved