首页 > 代码库 > struts2 select标签

struts2 select标签

headerValue : 默认值valueheaderKey :    默认namelist : 源数据 (可以在action方法里从数据库获取list)name : 被选数据存放的位置(这里我方在对象obj的属性值userName中<需在action中定义该对象>)listKey : 下拉选项的namelistValue : 下拉选项的valuevalue : 默认值1.第一个例子:<s:select list="{‘aa‘,‘bb‘,‘cc‘}" theme="simple" headerKey="00" headerValue="http://www.mamicode.com/00"></s:select>2.第二个例子:<s:select list="#{1:‘aa‘,2:‘bb‘,3:‘cc‘}"  label="abc" listKey="key" listValue="http://www.mamicode.com/value"  headerKey="0" headerValue="http://www.mamicode.com/aabb">3.第三个例子:<%java.util.HashMap map = new java.util.LinkedHashMap();map.put(1,"aaa");map.put(2,"bbb");map.put(3,"ccc");request.setAttribute("map",map);request.setAttribute("aa","2");%><s:select list="#request.map"  label="abc" listKey="key" listValue="http://www.mamicode.com/value" value="#request.aa"  headerKey="0" headerValue="http://www.mamicode.com/aabb"></s:select>headerKey headerValue 为设置缺省值4.第四个例子public class Program implements Serializable {    /**    serialVersionUID */    private static final long serialVersionUID = 1L;    private int programid;    private String programName;    public int getProgramid() {        return programid;    }    public void setProgramid(int programid) {        this.programid = programid;    }        public String getProgramName() {        return programName;    }    public void setProgramName(String programName) {        this.programName = programName;    }}

 

struts2 select标签