标签:
BEAN标签(name 是从别处得来的;id是自己的,相当于变量;property相当于变量的值)
①:
String str=request.getParameter("param");
out.println("str);
相当于:
<bean:parameter id="str" name="param"/> <bean:write name="str"/>
②:
<bean:write name="stu" property="stuId"/>
LOGIC标签:
①:<logic:present>角色是否存在
name变量或者bean是否存在。
②:<logic:iterate>
id:遍历的过程中,将其集合内元素起名为id,注意,此时元素可以为JavaBean.
设置name和property:某个JavaBean里面有一个属性是集合的情况。
//1
ArrayLis books=new ArrayList(); books.add("水浒传"); books.add("西游记"); session.setAttribute("books",books); //another page <logic:iterate id="book" name="books"> <bean:write name="book"/> </logic:iterate>
//2 include JavaBean:Student
ArrayList stus=new ArrayList();
Student stu1=new Student();
stu1.setStuId("001");
Student stu2=new Student();
stu2.setStuId("002");
Student stu3=new Student();
stu3.setStuId("003");
stus.add(stu1);
stus.add(stu2);
stus.add(stu3);
session.setAttribute("stus",stus);
//another page
<logic:iterate id="stu" name="stus">
<logic:write name="stu" property="stuId"/>
</logic:iterate>
//3include JavaBean:Student & jihe
Student stu4=new Student();
ArrayList phones=new ArrayList();
phones.add("00011");
phones.add("00022");
stu4.setPhones(phones);
session.setAttribute("phones",phones);
//another page
<logic:iterate id="phone" name="stu4" property="phones">
<logic:write name="phone"/>
</loigc:iterate>
标签:
原文地址:http://www.cnblogs.com/yaoxing365/p/4526742.html