BEAN标签(name 是从别处得来的;id是自己的,相当于变量;property相当于变量的值)

前提:

 String str=request.getParameter("param");
 out.println("str); 

相当于:

 <bean:parameter id="str" name="param"/>
 <bean:write name="str"/>

写stu.stuId。

<bean:write name="stu" property="stuId"/>

<logic:iterate>

id:遍历的过程中,将其集合内元素起名为id,注意,此时元素可以为JavaBean.

设置name和property:

①数组的情况。

 String[] colors=new String[]{"red","yellow","green"};
 request.setAttribute("colors", colors);

 <logic:iterate id="color" name="colors">
    <bean:write name="color"/>
 </logic:iterate>

②集合的情况。

1 //集合
 2 ArrayLis  books=new ArrayList();
 3 books.add("水浒传");
 4 books.add("西游记");
 5 request.setAttribute("books",books);
 6
 7 <logic:iterate id="book" name="books">
 8     <bean:write name="book"/>
 9 </logic:iterate>
10
11 Map map=new HashMap();
12 map.put("1","11");
13 map.put("2", "22");
14 request.setAttribute("map", map);
15
16 <logic:iterate id="e"  name="map">
17     <bean:write name="e" property="key"/>
18     <bean:write name="e" property="value"/>
19 </logic:iterate>

③某个集合里面有JavaBean的情况。

 1 // include JavaBean:Student
 2 ArrayList stus=new ArrayList();
 3 Student stu1=new Student();
 4 stu1.setStuId("001");
 5 Student stu2=new Student();
 6 stu2.setStuId("002");
 7 Student stu3=new Student();
 8 stu3.setStuId("003");
 9
10 stus.add(stu1);
11 stus.add(stu2);
12 stus.add(stu3);
13
14 session.setAttribute("stus",stus);
15
16 //another page
17 <logic:iterate id="stu" name="stus">
18   <logic:write name="stu" property="stuId"/>
19 </logic:iterate>

④Javabean里面有集合的情况。

 1 //include JavaBean:Student & jihe
 2 Student stu4=new Student();
 3 ArrayList phones=new ArrayList();
 4 phones.add("00011");
 5 phones.add("00022");
 6 stu4.setPhones(phones);
 7 session.setAttribute("stu4",stu4);
 8
 9 //another page
10
11 <logic:iterate id="phone" name="stu4" property="phones">
12     <logic:write name="phone"/>
13 </loigc:iterate>

基本STRUTS标签-学习笔记-Logic标签的更多相关文章

  1. 基本STRUTS标签-学习笔记-Bean标签

    <bean:include> 和标准的JSP标签<jsp:include>很相似,都可以用来包含其他Web资源的内容,区别在于<bean:include>标签把其它 ...

  2. struts 2学习笔记—初学struts 2

    首先我学习了struts 1.x与struts 2的区别: 1.struts 1.x的控制器类必须从Action类继承. 2.struts 2的控制器类可以是一个普通的类,也可以是ActionSupp ...

  3. HTML学习笔记之标签基础

    目录 1.基本标签 2.链接 3.图像 4.表格 5.列表 6.块与布局 1.基本标签 (1)标题与段落 标签 <h1> ~ <h6> 分别用于定义一至六级标题,标签 < ...

  4. 学习笔记_Java_day13_JSTL标签库(1、2、3、4、5、6、7、8)

    1.一种标签语言 day13 l  JSTL标签库(重点) l  自定义标签(理解) l  MVC设计模式(重点中的重点) l  Java三层框架(重点中的重点) JSTL标签库 1 什么是JSTL ...

  5. java web 学习笔记 - JSP标签编程

    1.JSP标签编程简介 标签编程在开发中并不常见,主要是为了更好的理解struts等框架的标签而打基础,完善相关知识体系. 标签编程分为: 一个继承自TagSupport的标签类,一个在WEB-INF ...

  6. HTML标签---学习笔记

    第一章 HTML标准结构学习: 顶层标签:html 投标签:head 主题标签:boby <html> <head> <meta charset="utf-8& ...

  7. struts2标签学习笔记(一)

    struts2所有标签都定义在一个s标签库里.虽然struts2把所有的标签都定义在URI为"/struts-tags"空间下,但依然可以对struts2标签进行简单的分类. 1. ...

  8. JSTL学习笔记(核心标签)

    一.JSTL标签分类: 核心标签 格式化标签 SQL标签 XML标签 JSTL函数 二.核心标签       引用方式:<%@ taglib prefix="c" uri=& ...

  9. html常用标签学习笔记

    本文内容: 前言:本文讲述的内容包括几类常用标签,以及这些标签的一些常用属性(有一些属性由于已经有CSS样式来代替,所以对于一些不重要的这里选择不讲) 排版标签 段落标签:p div span 标题标 ...

随机推荐

  1. POJ 3922A Simple Stone Game

    题目链接 A Sample Stone Game 题目大意:给定n,k,表示最初时有n个石头,两个人玩取石子游戏,第一个人第一次可以取1~n-1个石头,后面每个人最多可以拿走前面一个人拿走的个数的K倍 ...

  2. union all 简单用法

    select Y.ID,sum(cast(Y.m as int)) as hefrom(select top 10 a.ID,a.AlarmSource as m from dbo.AlarmInfo ...

  3. Wifi热点工具-青青草原WiFi

    有时只有有线网络,但手机需要上网,这时需要将笔记本作为无线热点. 青青草原WiFi,这个工具用起来挺方便,http://www.22zy.net/.

  4. Python3向网页POST数据

    还是以我的网页iciba为例 POST数据到www.selflink.cn/iciba/get0.php获取返回的查询结果 #coding:utf8 import urllib.request imp ...

  5. Displaying Alerts with UIAlertView

    UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Alert" message:@"You've ...

  6. c#匿名类 anonymous学习

    感谢http://blog.csdn.net/jjx0224/article/details/5887589 感谢http://hi.baidu.com/guodong828/blog/item/cc ...

  7. [Ramda] Simple log function for debugging Compose function

    const log = function(x){ console.log(x); return x; } const get = R.curry(function(prop, obj){ return ...

  8. centos x86_64--------------------------------系统调用

    http://blog.csdn.net/hmsiwtv/article/details/11022241 [root@monitor ~]# cat /usr/include/asm/unistd. ...

  9. SIGGRAPH 2014 之行

    当地时间8月8号: 经历十个多小时的飞行,在紧急出口旁的位置上忍受发动机的轰鸣声后,顺利降落温哥华机场.回答完加拿大边检的几个诸如为何而来,打算住哪儿的问题后,比较顺利出关.三十五加元的打车费及百分十 ...

  10. 今天再分享一个TextView内容风格化的类

    /* * Copyright (C) 2014 Jason Fang ( ijasonfang@gmail.com ) * * Licensed under the Apache License, V ...