id代表了一个Bean的名称
name代表了你需要叠代的属性如果没有name,那么id代表的那个东西应该是可以叠代的The collection to be iterated over MUST conform to one of the following requirements in order for iteration to be successful:
An array of Java objects (but not primitive data types such as "int")
An implementation of java.util.Collection, including ArrayList and Vector.
An implementation of java.util.Enumeration.
An implementation of java.util.Iterator.
An implementation of java.util.Map, including HashMap, Hashtable, and TreeMap. NOTE - See below for additional information about accessing Maps.
name代表了你需要叠代的属性如果没有name,那么id代表的那个东西应该是可以叠代的The collection to be iterated over MUST conform to one of the following requirements in order for iteration to be successful:
An array of Java objects (but not primitive data types such as "int")
An implementation of java.util.Collection, including ArrayList and Vector.
An implementation of java.util.Enumeration.
An implementation of java.util.Iterator.
An implementation of java.util.Map, including HashMap, Hashtable, and TreeMap. NOTE - See below for additional information about accessing Maps.
<bean:write name="test" property="pp" filter="true"/>
name="test" 是你通過循環(logic:iterate)得到的一個對象,你這個對象裏面必須
存在getPp()這樣的方法,你才可以這樣使用
bean里有setName,getName,等等
<logic:iterate id="employee" name="employees">
他只是在调用该页面中的ActionServlet中找到一个getemployees方法
不过例子调不通,所以很怀疑他这样对不对。
ActionServlet里面应该有session.setAttribute("employees", 集合或类),id是它实例化;
比如你在action中
MyJavaBean[] javabean = new MyJavaBean[3];
。
request.getSession().setAttribute("mybean",javabean);<logic:iterate id="id" name="mybean"
<bean:write name="id" ..
这里的name是一个数据集合,她相当于
for(int i =0; i<javabean.length; i++ )
{
<bean:write...//当然这里的write就相当于调用javabean[i].get方法
}
MyJavaBean[] javabean = new MyJavaBean[3];
。
request.getSession().setAttribute("mybean",javabean);<logic:iterate id="testId" name="mybean" property="myArr"...>
<tr>
<% UserData data = (UserData)testId;
String userName = data .getName();
String userPass = data.getPass();
%>
<td><%=userName%></td>
<td><%=userPass%></td>
</tr>
</logic:iterate>myArr对应在javaBean里面有get,set方法
然后就可以用了,testId是从集合myArr里面自动取出的实例,我们假设myArr里面装着一个个得user自定义类你啊明白啦?
显示的时候还是应该用struts的标签呀
这样的话你的jsp里面还是有scriptlet这样的东西,就不能算是java和jsp完全分离的
这不是好的代码,也没有整真利用好这个struts的框架
谢谢各位
我研究研究啊,多谢提点