关于struts使用html:select标签的默认选项

方法一:

 

<html:select property="id">  //这里一定不能再用vlue属性了,只用一个property就可以了   
 <c:forEach var="row" item="${rs.rows}">      
  <html:option value="row.id">  
               <c:out value="row.name"/>  
         </html:option>      
 </c:forEach>        
</html:select>

 

方法二:

 

jsp里:
<html:select property="userid">
      <html:options collection="userHtmlSelect" property="value" labelProperty="label"/>
</html:select>

ActionForm 里:
private   java.lang.String userid="admin";   //默认值

Action里:
form.setUserid("guest");//修改默认值
//设置下拉选项
List rs = new java.util.ArrayList();
             rs.add(new   org.apache.struts.util.LabelValueBean("管理员",
                     "admin"));
             rs.add(new   org.apache.struts.util.LabelValueBean("客人","guest"));
request.getSession().setAttribute("userHtmlSelect",rs);
return mapping.findForward("index");

 

方法三:

 

<html:select property= “m_select ” value= “C2 “>
<html:option value= “C1 “> 您的选择1 </html:option>
<html:option value= “C2 “> 您的选择2 </html:option>
<html:option value= “C3 “> 您的选择3 </html:option>
</html:select>

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值