首页 > 其他 > 详细

Struts2中 radio标签的详细使用方法

时间:2017-06-07 09:17:54      阅读:257      评论:0      收藏:0      [点我收藏+]

首先在页面中引入struts标签库:

<%@ taglib prefix="s" uri="/struts-tags"%>

在JSP页面中创建单选按钮radio的方法:

<s:radio list="#{‘1‘:‘先生‘,‘0‘:‘女士‘}" name="gender" value="1"/>

其中list中的键值对表示所有的选项,value表示设置的默认值,如果这个默认值是从后台传过来的,可以这样设置:

<s:radio list="#{‘1‘:‘先生‘,‘0‘:‘女士‘}" name="gender" value="gender.id"/>

当list属性为Action传过来的Map时 可以自动显示为key-value形式

<s:radio list="%{map}" name="gender" value="gender.id "/>

当list属性为Action传过来的List<Gender>时 需要添加 listKey listValue属性  listKey对应提交到数据库中的值  listValue对应显示的文本

<s:radio list="%{list}" name="gender" value="gender.id" listKey="id" listValue="genderText""/>

<s:radio name="test" id="test" list="%{#{1:‘全部‘,2:‘指定商品‘}}"  theme="simple" value="promotionScope" onchange=""></s:radio>

promotionScope为后台所传参数,<s:property value=“promotionScope”/>,在<s:radio>无需使用<s:property>标签

Struts2中 radio标签的详细使用方法

原文:http://www.cnblogs.com/OuZeBo/p/6955240.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!