Discussion on the use of s: list in the select tag to store map objects
- 2020-05-12 02:46:11
- OfStack
1, XXXAction. java
private List<Map<String, String>> maptest = null;
public List<Map<String, String>> getMaptest() {
return maptest;
}
public void setMaptest(List<Map<String, String>> maptest) {
this.maptest = maptest;
}
public String maptest(){
maptest = new ArrayList<Map<String,String>>();
Map<String, String> map = new HashMap<String, String>();
map.put("id", "1");
map.put("name", "dept1");
maptest.add(map);
map = new HashMap<String, String>();
map.put("id", "2");
map.put("name", "dept2");
maptest.add(map);
return SUCCESS;
}
2, test.jsp page
<s:select list="maptest" listKey="id" listValue="name"></s:select>
In the above form, you can display the contents of the drop-down list.