当前页面: 开发资料首页 → JSP 专题 → 求一个Struts例子
求一个Struts例子
摘要: 求一个Struts例子
求一个用html:select 和 html:options 组和用的例子 下拉菜单 要在Action中 返回一个集合
下拉菜单显示这个集合的内容
最好用到org.apache.stuts.util.LaelValueBean
selectList为在Action中获得的集合。
我晕
看样子你很菜
随便找个例子大同小异
Action中代码:
...
Hashtable t=new Hashtable();
t.put("1","1");
t.put("2","2");
t.put("3","3");
t.put("4","4");
request.setAttribute("options",t);
...
页面使用:
<options collection="options" property="key" labelProperty="value"/>
2.使用org.apache.struts.util.LabelValueBean
Action中代码:
...
Vector t=new Vector();
t.add(new org.apache.struts.util.LabelValueBean("1","一"));
t.add(new org.apache.struts.util.LabelValueBean("2","二"));
t.add(new org.apache.struts.util.LabelValueBean("3","三"));
t.add(new org.apache.struts.util.LabelValueBean("4","四"));
request.setAttribute("options",t);
...
页面使用:
<options collection="options" property="value" labelProperty="label"/>