基本STRUTS标签-学习笔记-Logic标签
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标签的更多相关文章
- 基本STRUTS标签-学习笔记-Bean标签
<bean:include> 和标准的JSP标签<jsp:include>很相似,都可以用来包含其他Web资源的内容,区别在于<bean:include>标签把其它 ...
- struts 2学习笔记—初学struts 2
首先我学习了struts 1.x与struts 2的区别: 1.struts 1.x的控制器类必须从Action类继承. 2.struts 2的控制器类可以是一个普通的类,也可以是ActionSupp ...
- HTML学习笔记之标签基础
目录 1.基本标签 2.链接 3.图像 4.表格 5.列表 6.块与布局 1.基本标签 (1)标题与段落 标签 <h1> ~ <h6> 分别用于定义一至六级标题,标签 < ...
- 学习笔记_Java_day13_JSTL标签库(1、2、3、4、5、6、7、8)
1.一种标签语言 day13 l JSTL标签库(重点) l 自定义标签(理解) l MVC设计模式(重点中的重点) l Java三层框架(重点中的重点) JSTL标签库 1 什么是JSTL ...
- java web 学习笔记 - JSP标签编程
1.JSP标签编程简介 标签编程在开发中并不常见,主要是为了更好的理解struts等框架的标签而打基础,完善相关知识体系. 标签编程分为: 一个继承自TagSupport的标签类,一个在WEB-INF ...
- HTML标签---学习笔记
第一章 HTML标准结构学习: 顶层标签:html 投标签:head 主题标签:boby <html> <head> <meta charset="utf-8& ...
- struts2标签学习笔记(一)
struts2所有标签都定义在一个s标签库里.虽然struts2把所有的标签都定义在URI为"/struts-tags"空间下,但依然可以对struts2标签进行简单的分类. 1. ...
- JSTL学习笔记(核心标签)
一.JSTL标签分类: 核心标签 格式化标签 SQL标签 XML标签 JSTL函数 二.核心标签 引用方式:<%@ taglib prefix="c" uri=& ...
- html常用标签学习笔记
本文内容: 前言:本文讲述的内容包括几类常用标签,以及这些标签的一些常用属性(有一些属性由于已经有CSS样式来代替,所以对于一些不重要的这里选择不讲) 排版标签 段落标签:p div span 标题标 ...
随机推荐
- ASP.NET MVC程序传值方式:ViewData,ViewBag,TempData和Session
转载原地址 http://www.cnblogs.com/sunshineground/p/4350216.html 在ASP.NET MVC中,页面间Controller与View之间主要有以下几种 ...
- Android MuPDF 部署
MuPDF是一款轻量级的开源软件,可以用来阅读PDF文件.下载完源代码以后,想要运行成功,除了Android SDK之外,还需要Android NDK环境,因此有点麻烦. 但是一旦安装完必须的环境以后 ...
- -webkit-appearance: none;去处select默认小箭头样式
Html <select class="sel_house_type"> <option value="0">请选择</optio ...
- C#获取当前应用程序所在路径及环境变量
一.获取当前文件的路径 string str1=Process.GetCurrentProcess().MainModule.FileName;//可获得当前执行的exe的文件名. string st ...
- 剑指OFFER之旋转数组的最小数字(九度OJ1386)
题目描述: 把一个数组最开始的若干个元素搬到数组的末尾,我们称之为数组的旋转.输入一个递增排序的数组的一个旋转,输出旋转数组的最小元素.例如数组{3,4,5,1,2}为{1,2,3,4,5}的一个旋转 ...
- linux之unlink函数解析
[lingyun@localhost unlink]$ cat unlink.c /********************************************************* ...
- Could not allocate CursorWindow size due to error -12 错误解决方法
04-29 11:13:54.284 13584-13584/com.uniubi.smartfrontdesk E/art: Throwing OutOfMemoryError "pthr ...
- UVa784 Maze Exploration
// 题意:输入一个迷宫,从*开始遍历,把可达点标记为字符# 注意迷宫边界不规则,要用strlen判断. #include<cstdio> #include<cstring> ...
- Chrome Apps将可以打包成iOS或Android应用
Chrome Apps 将可以在 iOS 和 Android 设备上独立运行了.开发者只要使用 Google今天 提供的工具集(toolchain)将自己的 Web App 打包,并将生成的应用上传到 ...
- Codeforces Round #115 A. Robot Bicorn Attack 暴力
A. Robot Bicorn Attack Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/17 ...