id是自己定义的,在循环里面要用到,name是对象集合中的一个对象,循环里面要显示这个对象的属性,property是用于对象里面的潜套,如果没有这样的就可以不用写。

解决方案 »

  1.   

    <logic:iterate id="employee" name="department">
    <bean:write name="employee" property="name">
    </logic:iterate>
    取得的是department集合中一个对象中的name属性值。
      

  2.   

    id是自己定义的,在循环里面要用到,name 是Formbean的名字.property是Form 中的变量值
    <logic:iterate id="employee" name="department">
        <tr>
            <td width="11%"><bean:write name="employee" property="sex"/> </td>
            <td width="11%"><bean:write name="employee" property="name"/> </td>
            <td width="11%"><bean:write name="employee" property="age"/> </td>
        </tr>
      

  3.   

    请问flying_cherry(flying) ,下面这个例子能运行成功吗?我那些值也是根据你解释的写了,不过我是没调通
    struts-config.xml内容:
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE struts-config PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 1.1//EN" "http://jakarta.apache.org/struts/dtds/struts-config_1_1.dtd">
    <struts-config>
      <form-beans>
        <form-bean name="workActionForm" type="src.workActionForm" />
      </form-beans>
      <action-mappings>
        <action name="workActionForm" path="/workAction" scope="request" type="src.workAction" validate="true" redirect="false">
          <forward name="success" path="/work.jsp" />
              </action>
      </action-mappings>
    </struts-config>workAction.java内容:
    package src;
    import org.apache.struts.action.*;
    import javax.servlet.http.*;
    public class workAction extends Action {
    public ActionForward
         execute(ActionMapping mapping,
                 ActionForm form, HttpServletRequest req,
                 HttpServletResponse res){
       workActionForm myform=(workActionForm)form;
        String[][] temp = {{"a1","a2","a3"},{"b1","b2","b3"}};
        myform.setabc(temp);
        return(mapping.findForward("success"));}
     
    }workActionForm.java内容:
    package src;
    import org.apache.struts.action.*;
    import javax.servlet.http.*;
    import javax.servlet.http.HttpServletRequest;
    public class workActionForm extends ActionForm {
      private String[][] abc = null;
      public void setabc(String[][] abc) {
       this.abc = abc;
      }
      public String[][] getabc() {
       return this.abc;
     }
     
       public ActionErrors validate(ActionMapping actionMapping, HttpServletRequest httpServletRequest) {
                  return null;
        }
        public void reset(ActionMapping actionMapping, HttpServletRequest httpServletRequest) {
        }
       }work.jsp内容:
    <%@ page contentType="text/html;charset=UTF-8" language="java" %>
    <%@ taglib uri="WEB-INF/struts-bean.tld" prefix="bean" %>
    <%@ taglib uri="WEB-INF/struts-html.tld" prefix="html" %>
    <%@ taglib uri="WEB-INF/struts-logic.tld" prefix="logic" %>
    <%@ taglib uri="WEB-INF/struts-nested.tld" prefix="nested" %>
    <%@ taglib uri="WEB-INF/struts-template.tld" prefix="template" %>
    <%@ taglib uri="WEB-INF/struts-tiles.tld" prefix="tiles" %>
    <html:html>
    <head>
    <title>
    work
    </title>
    </head>
    <body bgcolor="#ffffff">
    <h1>
    welcome to my test !!
    </h1>
    </body>
    </html:html>
    <html:form action="workAction.do" >
    <logic:iterate id="workActionForm" name="workActionForm" property="abc" offset="0" >
     <% String[] temp = (String[]) workActionForm; %>
     <%=temp[0]%> | <%=temp[1]%> | <%=temp[2]%> <p>
    </logic:iterate>
    </html:form>
      

  4.   

    <table width="75%" border="1" align="center" cellpadding="3">
      <tr align="center">
        <td width="16%">桌位号</td>
        <td width="19%">标准人数</td>
        <td width="22%">类型</td>
        <td width="43%">操作</td>
      </tr>
      <logic:present name="tables">    //如果存在名为"tables"的属性(实际上是一个ArrayList)
       <logic:iterate id="table" name="tables">    //循环该属性变量,将其中对象元素取出来,命名为"table"
       <tr>
       <td><bean:write name="table" property="tableID"/></td>  //显示"table"对象的属性
       <td><bean:write name="table" property="seats"/></td>
       <td><bean:write name="table" property="type"/></td>
       <td><html:link page="/TableUsing.do" paramId="tableID" paramName="table" paramProperty="tableID">安排</html:link>
       <html:link page="/TableBook.do" paramId="tableID" paramName="table" paramProperty="tableID">预订</html:link>
       </td>
       </tr>
       </logic:iterate>
      </logic:present>
    </table>上面是我在做东东时的部分代码,希望对你有帮助。其中的注释是现加上的,方便看懂。
    说明:“tables”是一个ArrayList类型的属性,在某个action中有:……
    TableBean tableBean=new TableBean();
    ArrayList tables=(ArrayList)tableBean.tableQuery(seats,tableType,ifSmoke);
    request.setAttribute("tables",tables);  //设置名为"tables"的属性,在jsp文件中取出来
    return(mapping.findForward("tablelist"));名为"tablelist"的Forward指向最开始代码所在的jsp文件。
      

  5.   

    另外,to wangshenghai():
    你的例子运行不通,具体问题实在是一言难尽。
    建议你还是找本书仔细看看,有个整体的概念。在csdn上只能是某个具体的问题不明白,问一下,得不到一个整体的概念的。