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. [C语言 - 5] 预处理

    编译之前的处理指令 A.宏定义 a. //Like static constant #define NUM 6 //The truth of macro define is replacing the ...

  2. POJ1061青蛙的约会(扩展欧几里得)

    #include <cstdio> #include <cstring> #include <algorithm> #include <math.h> ...

  3. ajax乱码问题 服务端 客户端 两种的解决方案--转载

    今天弄了一天的Ajax中文乱码问题,Ajax的乱码问题分为两种: 1. JavaScript输出的中文乱码, 比如:alert("中文乱码测试"); 2. 这第二种就是Ajax从服 ...

  4. SQL NULL Values

    NULL代表缺失的.未知的数据.表的列值默认是NULL.如果某个表的某个列不是NOT NULL的,那么当我们插入新纪录.更新已存在的记录时,可以不用为此列赋值,这意味着那个列保存为NULL值. NUL ...

  5. struts2文件下载 出现Can not find a java.io.InputStream with the name的错误

    成功代码: 前台界面jsp: <a style="text-decoration:none;" href="<%=path %>/main/frontN ...

  6. centos6.4上安装phpmyfaq

    phpmyfaq真是奇怪呀,官网上只能下载到当前的版本,无法下载以前的版本.官网为:http://www.phpmyfaq.de/ 官网上没有phpmyfaq的安装方法,我在网上找了下,这就个文章还比 ...

  7. mongo批量更新

    update的如果要批量更新是无能为力的,如果有多条匹配的结果,但结果是只能更新一条. 用bulk来进行处理 var bulk = db.HIS_ALARM.initializeUnorderedBu ...

  8. ireport启动闪退问题

    安装好ireport之后,双击ireport.exe启动程序只是掠过启动画面便毫无反应, 后来在网上找了下解决方法,才知道只因为ireport与jdk8不兼容, 于是下载了jdk6,并在ireport ...

  9. Cordova 3.0 Plugin 安装 及"git" command line tool is not installed

    根据http://docs.phonegap.com/en/edge/guide_cli_index.md.html#The%20Command-line%20Interface Windows命令行 ...

  10. 进程环境之getrlimit和setrlimit函数

    每个进程都有一组资源限制,其中一些可以用getrlimit和setrlimit函数查询和更改. #include <sys/resource.h> int getrlimit( int r ...