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. dll开发中遇到的问题

    刚碰到个问题,我的一个项目中引用了一个dll,这个dll又引用了另一个dll,我把这俩个都放在bin文件夹下,但是会报错,说第二个dll找不到.把它放到系统文件夹system32下就没事了. 但是遇到 ...

  2. MD5验证工具:md5sum

    linux 下 shell命令 ,制作md5码 也用于软件的md5校验     MD5算法常常被用来验证网络文件传输的完整性,防止文件被人篡改.MD5 全称是报文摘要算法(Message-Digest ...

  3. Unity3D之移植学习笔记:移植到Android平台

    首先,我们需要一台已经配置好可以开发Android应用的计算机,这里我使用的是Windows系统+Eclipse+ADT的开发环境,当然也可以使用Android Studio或者使用Mac系统都可以. ...

  4. 从零开始学android开发-通过WebService获取今日天气情况

    因为本身是在搞.NET方面的东东,现在在学习Android,所以想实现Android通过WebService接口来获取数据,网上很多例子还有有问题的.参考:Android 通过WebService进行 ...

  5. Middleware课程01-概述

    中间件是一种独立的系统软件或服务程序,分布式应用软件借助这种软件在不同的技术之间共享资源.中间件位于客户机/ 服务器的操作系统之上,管理计算机资源和网络通讯.是连接两个独立应用程序或独立系统的软件.相 ...

  6. PI-webservice06-调用外部webservice过程中注意问题

    1,SAP与.NET系统之间通过webservice来进行数据交互的过程中,格式是有要求的,要求.NET发布出来的webservice中的数据是用list来进行传输的,不能用datatable和lis ...

  7. Educational Codeforces Round 1 B. Queries on a String 暴力

    B. Queries on a String Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/59 ...

  8. Codeforces Round #327 (Div. 2) C. Median Smoothing 找规律

    C. Median Smoothing Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/591/p ...

  9. 现在的SEO最须要会点啥

    如今的SEO最须要会点啥,会飞天,会遁地,NONONO,不须要你这么流弊,咳咳,不瞎扯.在以往SEO的就是从搜索引擎中获取免费流量.是啊,曾经多好弄啊.而如今在我们不但须要流量还须要把流量进行转换,毕 ...

  10. [AngularJS] Directive using another directive by 'require'

    Directive can use another directive though 'require' keyword. angular.module('docsTabsExample', []) ...