1、假设存在如下类:
public class PropertyDesc
{
private int type;//确定值是以文本框显示还是列表显示
private String propertyName;
private String propertyValue;
private List<EntryDesv> propertyList;
……
}
public class EntryDesc
{
private int value;
private String UIDisplay;
……
}
2、将多个PropertyDesc对象放进HashMap中,方式如下:
Map<Integer, PropertyDesc> map = new HashMap<Integer, PropertyDesc>();
map.put(1, propertyDesc1);
map.put(2, propertyDesc2);
map.put(3, propertyDesc3);
……
request.setAttribute("map",map);
3、在页面可使用如下方式呈现:
<logic:iterate id="attr" indexId = "index" name="map">
<logic:equal name="attr" property="value.attrType" value="6">
<select size="1" name="select">
<logic:iterate id="list" name="attr" property="value.attrList">
<option selected value="<bean:write name="list" property="value"/>">
<bean:write name="list" property="UIDisplay"/>
</option>
<option value="<bean:write name="list" property="value"/>">
<bean:write name="list" property="UIDisplay"/>
</option>
</logic:iterate>
</select>
</logic:equal>
<logic:notEqual name="attr" property="value.attrType" value="6">
<input name="txtName" type="text" value="<bean:write name="attr" property="value.attrValue"/>"/>
</logic:notEqual>
</logic:iterator>
补充:
logic:iterator迭代HashMap
1、HashMap中存放普通的包装对象
Map<Integer, String> map=new HashMap<Integer, String>();
int index = 0;
map.put(++index, "Lily");
map.put(++index, "Lucy");
request.setAttribute("map", map);
<logic:iterate iterate id="var" name="map">
<bean:write name="var" property="key"/>
<bean:write name="var" property="value"/>
</logic:iterate>
2、HashMap中存放自定义的对象
//描述属性的对象,包含该对象的几个特征字段
AttributeDesc desc = new AttributeDesc();
Map<Integer, AttributeDesc > map=new HashMap<Integer, AttributeDesc >();
int index = 0;
map.put(++index, new String[]{"Lily", "Lucy"});
request.setAttribute("map", map);
<logic:iterate iterate id="var" name="map">
<bean:write name="var" property="key"/>
<bean:write name="var" property="value.属性名"/>
</logic:iterate>
3、HashMap中存放数组
int length = length of array;
String[] array = new String[length];
Map<Integer, String[]> map=new HashMap<Integer, String[]>();
int index = 0;
map.put(++index, new String[]{"Lily", "Lucy"});
request.setAttribute("map", map);
<logic:iterate id="var" name="map">
<bean:write name="var" property="key"/>
<logic:iterate id="str" name="var" property="value">
<bean:write name="str"/>
</logic:iterate>
</logic:iterate>
4、HashMap中存放List对象
List list = new ArrayList();
Map<Integer, List> map=new HashMap<Integer, List>();
int index = 0;
list.add("lucy");
map.put(++index, list);
request.setAttribute("map", map);
<logic:iterateid="user"name="map">
<bean:write name="user" property="key"/>
<logic:iterate name="user" property="value>
<bean:write name="value.属性名"/>
</logic:iterate>
</logic:iterate>
分享到:
相关推荐
Struts中logic标签的使用介绍了Struts中逻辑标签的使用
Struts Logic标签Struts Logic标签Struts Logic标签Struts Logic标签Struts Logic标签
struts-logic标签 自已讲课用的 初稿 PPT
Struts标签 logic标签所有应用源代码 看懂了这个,你就会明白bean标签所有的使用方法 我还上传了html标签、bean标签,这三种标签在Struts中用得最多的,希望能给你一些帮助
Struts2标签库Struts2标签库Struts2标签库Struts2标签库Struts2标签库Struts2标签库
Struts标签 -LOGIC标签
Struts标签库html标签、logic标签、bean标签
struts-logic.tld//struts-logic.tld
分别对struts中所有logic标签进行了详细的讲解,包括标签功能描述、参数描述、使用说明等。
struts-logic iterate标签学习指南 这标签还不错
struts2标签使用例子 struts2标签使用例子 struts2标签使用例子struts2标签使用例子
struts-logic.tld struts开发插件
struts中logic标签的汇总,孙卫琴老师struts书中的例子
我就是靠这个文档实现logic:iterate的循环的 struts 标签 logic:iterate使用 logic:iterate <br>第一页 是struts官方的说明, 第二页 是个例子 第三页 是我实现的arrayList放入标签的方法。 这是页面...
本文就Struts之logic标签库进行详细介绍,需要的朋友可以参考下
详细的介绍了如何使用struts中ec标签
介绍struts logic标签的用法,对于想了解STRUTS LOGIC标签有很大帮助。