struts使用下拉菜单的三种方式
2007-08-23 15:37
316 查看
struts中使用单选按钮有三种方式:
1.使用<html:option>标签
<html:select property="city">
<html:option value="010">北京市</html:option>
<html:option value="020">广州市</html:option>
<html:option value="021">上海市</html:option>
</html:select>
2.使用<html:optionsCollection>标签
1)在ActionForm中加入字段
private List cityList=new ArrayList();
2)加入必须的getter方法
public List getCityList() {
return cityList;
}
3)在reset方法内给cityList填充内容
cityList.add(new LabelValueBean("北京市","010"));
cityList.add(new LabelValueBean("广州市", "020"));
cityList.add(new LabelValueBean("上海市", "021"));
4)JSP标签中使用
<html:select property="city2">
<html:optionsCollection property="cityList" label="label" value="value"/>
</html:select>
3.使用<html:options>标签
<%List cityList=new ArrayList();
cityList.add(new LabelValueBean("北京市","010"));
cityList.add(new LabelValueBean("广州市", "020"));
cityList.add(new LabelValueBean("上海市", "021"));
request.setAttribute("list",cityList); //必须是request对象
%>
<html:select property="city3">
<html:options collection="list" labelProperty="label" property="value"/>
</html:select>
1.使用<html:option>标签
<html:select property="city">
<html:option value="010">北京市</html:option>
<html:option value="020">广州市</html:option>
<html:option value="021">上海市</html:option>
</html:select>
2.使用<html:optionsCollection>标签
1)在ActionForm中加入字段
private List cityList=new ArrayList();
2)加入必须的getter方法
public List getCityList() {
return cityList;
}
3)在reset方法内给cityList填充内容
cityList.add(new LabelValueBean("北京市","010"));
cityList.add(new LabelValueBean("广州市", "020"));
cityList.add(new LabelValueBean("上海市", "021"));
4)JSP标签中使用
<html:select property="city2">
<html:optionsCollection property="cityList" label="label" value="value"/>
</html:select>
3.使用<html:options>标签
<%List cityList=new ArrayList();
cityList.add(new LabelValueBean("北京市","010"));
cityList.add(new LabelValueBean("广州市", "020"));
cityList.add(new LabelValueBean("上海市", "021"));
request.setAttribute("list",cityList); //必须是request对象
%>
<html:select property="city3">
<html:options collection="list" labelProperty="label" property="value"/>
</html:select>
相关文章推荐
- struts使用单选按钮的三种方式
- 使用 Spring 更好地处理 Struts 动作三种整合 Struts 应用程序与 Spring 的方式
- 使用 Spring 更好地处理 Struts 动作(三种整合 Struts 应用程序与 Spring 的方式)
- 使用 Spring 更好地处理 Struts 动作(三种整合 Struts 应用程序与 Spring 的方式)
- 使用 Spring 更好地处理 Struts 动作三种整合 Struts 应用程序与 Spring 的方式[摘]
- Log4net日志使用教程-控制台、文本、数据库三种记录方式
- 使用Axis2方式发布webService的三种方式
- Struts2.5使用通配符的方式实现动态方法调用报错
- guice基本使用,三种注入方式(二)
- C# using 三种使用方式
- 盛大游戏技术总监徐峥:Unity引擎使用的三种方式
- new有三种使用方式:plain new、nothrow new、placement new.
- eclipse安装插件的方式 三种:links、eclipse中使用插件安装向导安装、直接copy插件到对应的eclipse目录 MyEclipse10安装SVN插件
- android sqlite使用之模糊查询数据库数据的三种方式
- css的三种定位方式使用探讨
- Struts2中jsp前台传值到action后台的三种方式以及valueStack的使用
- iOS项目开发实战——使用三种方式实现页面跳转与参数传递(一)
- spring4笔记----使用装配注入合作者Bean的三种方式
- android sqlite使用之模糊查询数据库数据的三种方式
- Java多线程学习1,使用线程的三种方式