小弟刚接触webwork,遇到一个关于使用下拉框问题,弄了很久极端郁闷,请大家帮忙解答,谢谢,在线等!
jsp里这样写的:
<ww:select label= "省份 " list= "provinces " name= "province " listKey= "key " listValue= "value "/>
运行jsp后就报:
java.lang.RuntimeException: tag select, field list: You must specify a collection/array/map/enumeration/iterator. Example: people or people.{name},而且页面显示不出下拉框,请大家帮忙看一下,感激不尽!
对应的action是:
public class GreetingAction2Version extends ActionSupport {
String greeting;
String province;
List provinces = new ArrayList();
public GreetingAction2Version() {
provinces.add(new ProvinceCls( "key1 ", "value1 "));
provinces.add(new ProvinceCls( "key2 ", "value2 "));
provinces.add(new ProvinceCls( "key3 ", "value3 "));
provinces.add(new ProvinceCls( "key4 ", "value4 "));
}
public String getProvince() {
return province;
}
public void setProvince(String province) {
this.province = province;
}
public List getProvinces() {
return provinces;
}
public void setProvinces(List provinces) {
this.provinces = provinces;
}
public String getGreeting() {
return greeting;
}
public String execute() throws Exception {
……
}
//内部类
public static class ProvinceCls {
String key;
String value;
public ProvinceCls(String key, String value) {
this.key = key;
this.value = value;
}
public String getKey() {
return key;
}
public String getValue() {
return value;
}
}
}
------解决方案--------------------我看了一下文档,发现你的标签部分没有错误。
所以,建议你在显示标签之前,答应provinces,看看它是不是空?
up
------解决方案--------------------你用html标签试一下