主题:如何得到logic:iterate循环中的indexId
1个回答
展开全部
请各位大侠指教,
: 还有这种用法 场景:有一个JavaBeans:如下: public class LabelValueBean implements Serializable { public LabelValueBean(String label, String value) { this.label = label; this.value = value; } private String label; public String getLabel() { return this.label; } public void setLabel(String label) { this.label = label; } private String value; public String getValue() { return this.value; } public void setValue(String value) { this.value = value; } public String toString() { StringBuffer sb = new StringBuffer("LabelValueBean["); sb.append(this.label); sb.append(", "); sb.append(this.value); sb.append("]"); return (sb.toString()); }} 这是非常普通的JavaBeans, 如果ActionForm是这样: public class TestBean extends ActionForm { ..... private List lvbeans = new ArrayList(); .....} 使用indexed属性,TestBean类如下: public class TestBean extends ActionForm { ..... private List lvbeans = new ArrayList(); public TestBean(){ //初始化数值 lvbeans.add(new LabelValueBean("1", "1")); lvbeans.add(new LabelValueBean("2", "2")); lvbeans.add(new LabelValueBean("3", "3")); } public LabelValueBean getLvbeans(int index) { return (LabelValueBean)lvbeans.get(index); } public List getLvbeans() { return lvbeans; } .....} 注意上述两个get方法很重要,Jsp页面代码如下: Test: 这样,运行后的输出结果是: Test: 这样修改TestBean中的List中的LabelValueBean数值了。
: 还有这种用法 场景:有一个JavaBeans:如下: public class LabelValueBean implements Serializable { public LabelValueBean(String label, String value) { this.label = label; this.value = value; } private String label; public String getLabel() { return this.label; } public void setLabel(String label) { this.label = label; } private String value; public String getValue() { return this.value; } public void setValue(String value) { this.value = value; } public String toString() { StringBuffer sb = new StringBuffer("LabelValueBean["); sb.append(this.label); sb.append(", "); sb.append(this.value); sb.append("]"); return (sb.toString()); }} 这是非常普通的JavaBeans, 如果ActionForm是这样: public class TestBean extends ActionForm { ..... private List lvbeans = new ArrayList(); .....} 使用indexed属性,TestBean类如下: public class TestBean extends ActionForm { ..... private List lvbeans = new ArrayList(); public TestBean(){ //初始化数值 lvbeans.add(new LabelValueBean("1", "1")); lvbeans.add(new LabelValueBean("2", "2")); lvbeans.add(new LabelValueBean("3", "3")); } public LabelValueBean getLvbeans(int index) { return (LabelValueBean)lvbeans.get(index); } public List getLvbeans() { return lvbeans; } .....} 注意上述两个get方法很重要,Jsp页面代码如下: Test: 这样,运行后的输出结果是: Test: 这样修改TestBean中的List中的LabelValueBean数值了。
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询