zoukankan      html  css  js  c++  java
  • struts2标签之<s:select>

    http://blog.csdn.net/moliqin/article/details/3753570

    1.第一个例子:

    <s:select list="{'aa','bb','cc'}" theme="simple" headerKey="00" headerValue="00"></s:select>

    2.第二个例子:

    <s:select list="#{1:'aa',2:'bb',3:'cc'}"  label="abc" listKey="key" listValue="value"  headerKey="0" headerValue="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="value"
     value="#request.aa"  headerKey="0" headerValue="aabb"></
    s:select
    >
    headerKey headerValue 为设置缺省值
    摘抄自 http://www.cnblogs.com/modou/articles/1326683.html

    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;
        }
    }

    在 xxx extends  extends ActionSupport {
        private  List<Program> programs ;
           public List<Program> getPrograms() {
            return programs;
        }
        public void setPrograms(List<Program> programs) {
                this.programs = programs;
        }
    }
    在jsp页面
          <s:select list="programs "  listValue="programName " listKey="programid "  name="program" id="program"
                 headerKey="0l" headerValue="    "   value="bean.programid "
                 ></s:select>  
    programs为在action里面的list,programName为<option value="xxx">value</option>对应bean里面的字段programName 
    programid为<option value="xxx",对应bean里面的字段programid

    value="bean.programid "为设定select被选中的值,s:select 会自动在 bean选中 key对应的值

  • 相关阅读:
    C/C++编程可用的Linux自带工具
    安装gcc及其依赖
    Linux上编译hadoop-2.7.1的libhdfs.so和libhdfs.a
    gcc链接参数--whole-archive的作用
    jdb调试程序
    Exception in thread "main" java.lang.Error: Unresolved compilation problem
    动态规划与分治、备忘录的区别
    leetcode-unique paths
    LeetCode总结 -- 一维动态规划篇
    编程技巧
  • 原文地址:https://www.cnblogs.com/lbangel/p/3116630.html
Copyright © 2011-2022 走看看