<s:doubleselect>
用于生成俩个联动的下拉框,基本属性如下:
1、name/doubleName:第一个/第二个下拉框的名称
2、list/doubleList:生成第一个/第二个下拉框的集合
3、listKey/doubleListKey:生成第一个/第二个下拉框的选项的value属性
4、listValue/doubleListValue:生成第一个/第二个下拉框的选项显示的文字
示例:
- action配置
<action name="provinces" class="com.pb07.demo01.Provinces" method="toAdd">
<result>/jsp/07_联动下拉框/01_联动下拉框.jsp</result>
</action>
- action类代码
1、JavaBean
public class Province {
//省份ID
private int provinceId;
//省名称
private String provinceName;
//get set方法及构造方法略
}
public class City {
//省份对象
private Province province;
//城市ID
private int cityId;
//城市名称
private String cityName;
//get set方法及构造方法略
}
2、action
public class Provinces extends ActionSupport {
Map<Province, List<City>> map;
public String toAdd() throws Exception {
Province province1 = new Province(1, "江苏省");
Province province2 = new Province(2, "山东省");
List<City> cList1 = new ArrayList<City>();
List<City> cList2 = new ArrayList<City>();
City c1 = new City(province1, 1, "徐州市");
City c2 = new City(province1, 2, "南京市");
City c3 = new City(province2, 3, "山东的城市一");
City c4 = new City(province2, 4, "山东的城市二");
cList1.add(c1);
cList1.add(c2);
cList2.add(c3);
cList2.add(c4);
map = new HashMap<Province, List<City>>();
map.put(province1, cList1);
map.put(province2, cList2);
return SUCCESS;
}
public Map<Province, List<City>> getMap() {
return map;
}
public void setMap(Map<Province, List<City>> map) {
this.map = map;
}
}
- 显示页面代码
- 效果