您现在的位置是:首页 >

单选按钮控件 struts使用单选按钮的三种方式

火烧 2021-06-29 21:15:10 1062
trut 使用单选按钮的三种方式    trut 中使用单选按钮有三种方式   使用 lt :o tio gt 标签   lt : elect ro erty= city gt    lt :o t

struts使用单选按钮的三种方式  

  struts中使用单选按钮有三种方式

   使用<:option>标签

  <:select property= city >

  <:option value= >北京市</:option>

  <:option value= >广州市</:option>

  <:option value= >上海市</:option>

  </:select>

   使用<:optionsCollection>标签

   )在ActionForm中加入字段

单选按钮控件 struts使用单选按钮的三种方式

  private List cityList=new ArrayList();

   )加入必须的getter方法

  public List getCityList() {

  return cityList;

  }

   )在reset方法内给cityList填充内容

  cityList add(new LabelValueBean( 北京市 ));

  cityList add(new LabelValueBean( 广州市 ));

  cityList add(new LabelValueBean( 上海市 ));

   )JSP标签中使用

  <:select property= city >

  <:optionsCollection property= cityList label= label value= value />

  </:select>

   使用<:options>标签

  <%List cityList=new ArrayList();

  cityList add(new LabelValueBean( 北京市 ));

  cityList add(new LabelValueBean( 广州市 ));

  cityList add(new LabelValueBean( 上海市 ));

  request setAttribute( list cityList); //必须是request对象

  %>

  <:select property= city >

  <:options collection= list labelProperty= label property= value />

lishixinzhi/Article/program/Java/ky/201311/28298  
永远跟党走
  • 如果你觉得本站很棒,可以通过扫码支付打赏哦!

    • 微信收款码
    • 支付宝收款码