posts - 0,  comments - 17,  trackbacks - 0
<%@ page contentType="text/html; charset=GBK" %> 
<%@ page import="java.util.*" %> 

<%@ taglib uri="http://java.sun.com/jstl/core" prefix="c" %> 
<html> 
  
<head> 
    
<title>JSTL测试1--c:forEach循环</title> 
  
</head> 

  
<body> 
一、整数 
    
<c:forEach var="i" begin="1" end="10" step="1"> 
      
<c:out value="" />
    
</c:forEach><p>   


二、计算x的平方 
   
<table>  
   
<tr><th>Value</th>  
    
<th>Square</th></tr>  
    
<c:forEach var="x" begin="0" end="10" step="2">  
    
<tr><td><c:out value=""/></td>  
        
<td><c:out value="0"/></td></tr>  
   
</c:forEach>  
  
</table> <p> 
三、字符串
"47,52,53,55,46,22,16,2" 分隔. 
   
<table border="1"> 
   
<c:forTokens items="47,52,53,55,46,22,16,2" delims="," var="dailyPrice"> 
    
<tr><td><c:out value=""/></td></tr> 
   
</c:forTokens> 
   
</table><p> 
四、使用步长 
   
<table>  
    
<tr><th>second</th>  
    
<th>second</th></tr>  
    
<c:forEach var="seconds" begin="0" end="1800" step="60">  
    
<tr><td><c:out value=""/></td>  
        
<td><c:out value=""/></td></tr>  
   
</c:forEach>  
  
</table> <p> 
五、对数组进行循环
<p> 
  
<% int ai[] = {1020304050}; 
  pageContext.setAttribute(
"ary", ai); 
  
%> 
  
<c:forEach var="i" items=""> 
    
<c:out value=""/>* 
  
</c:forEach><p> 

 
<% 
   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 + "<br>");  
    
for(int i=0;i<cookies.length; i++// 循环列出所有可用的Cookie  
    {  
     sCookie
=cookies[i];  
      sname
=sCookie.getName();  
      name 
= sCookie.getValue();  
      out.println(sname 
+ "->" + name + "<br>");  
    }  
  }   
%>  
  
<table border="1" align="center">  
   
<tr><th>Cookie Name</th>  
    
<th>Cookie Value</th></tr>  
    
<c:forEach var="cook" items="">  
    
<tr><td><c:out value=""/></td>  
        
<td><c:out value=""/></td></tr>  
   
</c:forEach>  
  
</table> <p> 

六、字符串数组循环 
 
<% String as[] = { 
            
"A first string""La deuxieme string""Ella troisiemo stringo" 
        }; 
        request.setAttribute(
"stringArray", as); 
 
%><p> 
 
<c:forEach var="string" items=""> 
  
<c:out value=""/><br> 
 
</c:forEach> 
七、枚举 
 
<% 
 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); 
%> 

   
<c:forEach var="item" items="" begin="2" end="10" step="2"> 
     
<c:out value=""/><br> 
   
</c:forEach><p> 
八、map
<p> 
   
<c:forEach var="prop" items="" begin="1" end="5"> 
     
<c:out value=""/> = <c:out value=""/><br> 
   
</c:forEach> 

  

 
</body> 
</html> 
posted on 2008-03-29 21:18 xyz 阅读(2330) 评论(0)  编辑  收藏 所属分类: 网络文摘

只有注册用户登录后才能发表评论。


网站导航:
 

<2024年5月>
2829301234
567891011
12131415161718
19202122232425
2627282930311
2345678

留言簿

随笔档案(1)

文章分类(44)

文章档案(46)

收藏夹(1)

Adobe

AOP

API

appServer

BI

c

  • c-free
  • codeblocks
  • codelite
  • CodeLite IDE 是一个强大的开源,跨平台的 C/C++整合开发环境. 支持包括 Windows、Linux 和 Mac 系统下运行
  • codelite官网
  • dev-c++
  • Dev-C++是一个C&C++开发工具,它是一款自由软件,遵守GPL协议。
  • GCC
  • GCC 原名为 GNU C 语言编译器(GNU C Compiler),因为它原本只能处理 C语言。GCC 很快地扩展,变得可处理 C++。之后也变得可处理 Fortran、Pascal、Objective-C、Java, 以及 Ada 与其他语言。

Cache

CMS

DB

eclipse

FreeMarker

hibernate

html5

ibatis

java

jquery

js

json

Linux

Log

mail server

mobile

mysql

oauth

openID

other

PHP

portal

report

Scheduler

schema

Security

SOA

spring

struts

UI原型设计

w3c

Wap

webservice

xml

供应链管理

博客链接

好网站

工作流

开源网

招聘

插件下载

操作系统

构建可伸缩的系统

构建工具

测试

  • IETest
  • IE官网
  • OpenSTA
  • Siege
  • Siege是一个压力测试和评测工具,设计用于WEB开发这评估应用在压力下的承受能力

游戏

源码托管

经营

资源

金融/财务

搜索

  •  

最新评论