专注于互联网--专注于架构

最新标签
网站地图
文章索引
Rss订阅

首页 »Java教程 » 单选按钮:struts使用单选按钮的 3种方式 »正文

单选按钮:struts使用单选按钮的 3种方式

来源: 发布时间:星期四, 2009年1月15日 浏览:260次 评论:0
  struts中使用单选按钮有 3种方式:

  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= ArrayList;

  2)加入必须getter思路方法

public List getCityList {
  cityList;
}


  3)在re思路方法内给cityList填充内容

   cityList.add( LabelValueBean("北京市","010"));
   cityList.add( LabelValueBean("广州市", "020"));
   cityList.add( LabelValueBean("上海市", "021"));


  4)JSP标签中使用

<html:select property="city2">
 <html:optionsCollection property="cityList" label="label" value="value"/>
</html:select>


  3.使用<html:options>标签

<%List cityList= ArrayList;
cityList.add( LabelValueBean("北京市","010"));
cityList.add( LabelValueBean("广州市", "020"));
cityList.add( LabelValueBean("上海市", "021"));
request.Attribute("list",cityList); //必须是request对象
%>
<html:select property="city3">
 <html:options collection="list" labelProperty="label" property="value"/>
</html:select>


0

相关文章

读者评论

发表评论

  • 昵称:
  • 内容: