zoukankan      html  css  js  c++  java
  • Struts2中 radio标签的详细使用方法

    首先在页面中引入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>标签

    取值

    var promotionScope= $("input[name='promotionScope']:checked").val();
      if(promotionScope == null){
        alert("请选择活动范围");
        return false;
    }
  • 相关阅读:
    webpack初体验
    Sql server 数据库 单用户切换为多用户
    JAVA加密
    TransactionScrope 2
    TransactionScrope
    ORA-14450
    C#.NET 各种连接字符串
    如何获取得到新浪的授权?
    加载JSON文件,Plist文件
    屏幕截图
  • 原文地址:https://www.cnblogs.com/OuZeBo/p/6955240.html
Copyright © 2011-2022 走看看