正文

HTML标记库 - 下拉列表多选列表2007-03-13 10:31:00

【评论】 【打印】 【字体: 】 本文链接:http://blog.pfan.cn/hurongliang/23909.html

分享到:

html:select html:select 生成一个HTML的<select>标记,可以使用multiple 属性创建单选或多选列表。 multiple属性设置是否可以多选 size 设置页面显示多少个,单选默认为1,多选默认为全部。 html:option label值有两个来源: 1.  <html:option>和</html:option>之间的内容 <html:option value=”1”>大一</html:option> 2.  使用html:option标签的key、locale和bundle属性 <html:option value=”1” bundle=”school” key=”grade”/> bundle指定资源束,locale指定特定的语言环境,key指定资源束中的特定键。 在struts-config.xml中定义了如下的资源束: struts-config.xml: <message-resources parameter=”cn.rolia.struts. ApplicationResources” key=”school”/> html:options 可以将可选的值放到一个集合中,然后用html:options将此集合作为select的值。 先在页面范围里定义一个Vector,在html:option中的collection属性指定为这个Vector:     <%     Vector colors = new Vector();     colors.add(new org.apache.struts.util.LabelValueBean("粉红色","pink"));     colors.add(new org.apache.struts.util.LabelValueBean("紫色","purple"));     colors.add(new org.apache.struts.util.LabelValueBean("灰色","gray"));     colors.add(new org.apache.struts.util.LabelValueBean("褐色","brown"));     pageContext.setAttribute("color",colors);      %>     <html:select property="color2" multiple="true">       <html:options collection="color"                    property="value"                    labelProperty="label" />     </html:select> property表示实际值,labelProperty表示页面显示的值。 html:optionsCollection 在FormBean里定义一个Bean而不是像html:options那样在页面里定义Collection。

阅读(7909) | 评论(0)


版权声明:编程爱好者网站为此博客服务提供商,如本文牵涉到版权问题,编程爱好者网站不承担相关责任,如有版权问题请直接与本文作者联系解决。谢谢!

评论

暂无评论
您需要登录后才能评论,请 登录 或者 注册