testLogicBean2.jsp
上传用户:jishiqi_cj
上传日期:2022-08-08
资源大小:24765k
文件大小:1k
- <%@ page language="java" %>
- <%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
- <%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
- <%@ page import = "test.Person" %>
- <%@ page import = "java.util.ArrayList" %>
- <%
- ArrayList list1 = new ArrayList();
- list1.add("Tom");
- list1.add("Billy");
- list1.add("Kessy");
- list1.add("Nansy");
- %>
- <logic:iterate id="item"
- collection="<%=list1%>"
- indexId="index"
- offset="1"
- length="2">
- <%=index%>. <%=item%><br>
- </logic:iterate>
- <%
- pageContext.setAttribute("bean1", list1, PageContext.PAGE_SCOPE);
- %>
- <hr>
- <logic:iterate id="item"
- name="bean1"
- scope="page"
- indexId="index">
- <%=index%>. <%=item%><br>
- </logic:iterate>
- <hr>
- <%
- ArrayList users = new ArrayList();
- users.add(new Person("Tom",12));
- users.add(new Person("Billy",24));
- users.add(new Person("Kessy",36));
- pageContext.setAttribute("stuff", users, PageContext.PAGE_SCOPE);
- %>
- <logic:iterate id="user"
- name="stuff"
- type="test.Person"
- indexId="index" >
- <%=index%>.
- <bean:write name="user" property="name" />
- <%=user.getAge()%>
- <br>
- </logic:iterate>