struts中的迭代输出

<%@ page language="java" imp

ort="java.util.*,org. spring framework.beans.factory.BeanFactory" pageEncoding="UTF-8"%>
<%@ taglib uri=" http:// struts .apache.org/tags-logic" prefix="logic"%>
<%@ taglib uri=" http:// struts .apache.org/tags-bean" prefix="bean"%>
<%@ taglib uri=" http:// java.sun.com/ jsp / jstl /core" prefix="c" %>
<%@ page language="java" import="org. spring framework.core.io.ClassPathResource"%>
<%@ page language="java" import="com.zb.entity.NewObj,com.zb.dao.NewObjDAO"%>
<%@ page language="java" import="org. spring framework.beans.factory. xml .XmlBeanFactory"%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
     <title> 标签测试</title>
    <meta http-equiv="pragma" content="no-cache">
    <meta http-equiv="cache-control" content="no-cache">
  </head>
  <body>
<%
// 测试数组
List li=new ArrayList();
li.add("123");
li.add("234");
li.add("456");
request.setAttribute("li",li);

// 测试map
HashMap map=new HashMap();
map.put("1","111");
map.put("2","222");
map.put("3","333");
request.setAttribute("map",map);

// 测试bean
ClassPathResource resource = new ClassPathResource("../applicationContext. xml ");
BeanFactory factory = new XmlBeanFactory(resource);
NewObjDAO newobjdao=(NewObjDAO)factory.getBean("NewObjDAO");
List nlist=newobjdao.getList();
request.setAttribute("nlist",nlist);

// 测试带分隔符的字符串
String movie="好想有个家,爱你一万年,今天,冰雨";
request.setAttribute("movie",movie);
 %>
 
 <!-- 绑 定ArrayList -->

<logic:present name="li">
    <logic:iterate id="l" indexId="id" name="li">
        <bean:write name="l"/>
        <br>
    </logic:iterate>

</logic:present>

 <!-- 绑 定map --><br><br>
 
 <logic:present name="map">
    <logic:iterate id="l" indexId="id" name="map">
        <bean:write name="l" property="key"/>
        <bean:write name="l" property="value"/>
        <br>
    </logic:iterate>

</logic:present>

 <!-- 绑 定beanlist 其中offset表示第二个元素开始遍历(索引从0开始),length表示遍历元素的个数 --><br><br>

 <logic:present name="nlist">
    <logic:iterate id="l" indexId="id" name="nlist"  offset="1" length="4">
        <bean:write name="l" property="id"/> 
        <bean:write name="l" property="name"/> 
        <bean:write name="l" property="addtime"/> 
        <br>
    </logic:iterate>

</logic:present>

</body>
</html>

你可能感兴趣的:(java,spring,bean,cache,struts)