关于struts使用html:select标签的默认选项
2009-11-27 10:53
791 查看
方法一:
<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>
<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>
相关文章推荐
- 关于使用select标签,去掉重复选项的问题。默认首选项不被去除。
- java和struts使用中的一点总结--关于写在页面上的select域的选项选中后保存状态的办法!
- 在struts中html:select 标签的disabled属性中使用java代码
- struts中htmlselect标签和htmloptions 的使用
- html的select标签怎么让其显示一默认option选项
- struts中html:select标签和html:options 的使用(转)
- HTML中的<select>标签如何设置默认选中的选项
- 关于struts2 select标签默认样式的修改
- 关于html中使用img标签显示图片问题
- 关于Select option默认选中及查询后选项值保留的问题
- HTML:关于Select中的OPTGROUP使用
- struts中使用多选的 html:select
- HTML中使用struts标签的方法
- Asp.net MVC中关于@Html标签的使用
- Struts中 html:radio,html:multibox,html:select 使用实例
- Struts Html:Checkbox 标签使用技巧
- HTML中的<select>标签如何设置默认选中的选项
- HTML中的<select>标签如何设置默认选中的选项
- html中的select标签使用记录
- Struts html标签的使用及说明