logic:iterate,这么简单也出错! 只有请教大家

javaGhost
07-09-14 2 220

<%@ page language="java" pageEncoding="gb2312"%>
<%@ page import="java.util.HashMap"%>

<%@ taglib uri="http://struts.apache.org/tags-bean" prefix="bean"%>
<%@ taglib uri="http://struts.apache.org/tags-html" prefix="html"%>
<%@ taglib uri="http://struts.apache.org/tags-logic" prefix="html"%>

<html>
  <head>
    <title>test iterate</title>
  </head>
  <body>
  <%
  HashMap countries=new HashMap();
  countries.put("country1","中国");
  countries.put("country2","美国");
  countries.put("country3","英国");
  request.setAttribute("countries",countries);
  %>
  <logic:iterate id="one" name="countries">
    <bean:write name="one" property="key"/>:
    <bean:write name="one" property="value"/>
  </logic:iterate>
  </body>
</html>

javaGhost
2007-09-14 15:54

这是照抄的例子
非常简单
却出错!!!
[该贴被javaGhost于2007年09月14日 15:55修改过]

javaGhost
2007-09-14 16:07

首先在 web.xml中没配置 tld

其次,应该把<%@ taglib uri="http://struts.apache.org/tags-bean" prefix="bean"%> 改为<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>