谢谢!

解决方案 »

  1.   

    <label><html:radio property="xxx">选中</label></html:radio>
    <label><html:radio property="yyy">未选中</html:radio></label>LZ试试吧!呵呵
      

  2.   

    你需要在Action中先给这个RADIO控件赋值,很简单,直接用SET就行了
      

  3.   

    在</html>的最后加上(就是说当页面执行完时)<script>
     document.all("sex")[0].checked=true;//第一个radio选中
    </script>
      

  4.   

    试试这个
    <html:radio property="xxx" CHECKED>选项</label></html:radio>
      

  5.   

    你需要在Action中先给这个RADIO控件赋值,很简单,直接用SET就行了-----------------------
    这个赋值好像在而面载入的时候不起作用。
      

  6.   

    javapassion(村长赵大宝) ( ) 信誉:100 -----------------------
    没看明白你的啥意思呀!hackangcn(龙卷风) ( ) 信誉:100 
    ---------------------------------
    你的只是简单选中,我是要在后台取出数据,根据数据来选中的。
    suncheng_hong(亮) ( ) 信誉:100 
    -----------------------------------------
    没有CHECKED这个属性的。
      

  7.   

    从数据库中取出数据后,在action中,把该值(就是html:radio的name对应的)set进Formbean去。你那些普通的html:text是怎么set到bean里面的,这个也类是。
      

  8.   

    在action中????请问应该怎么set .谢谢!!!我在bean里set了不行?不知道怎么在action里set.
      

  9.   

    ..上班时间不能聊q。你在普通的html:text是在bean里set,那么这个也一样,在哪里set无所谓,只要最后页面的FromBean里面有值就可以了。你说的不行,使页面报错,还是不出来?
      

  10.   

    我看不到你具体的代码,不知道你错在哪里。
    反正这个思路是可以用的。要不我发我的例子给你看看:Action中:
    TUserinfo userInfo = userInfoDAO.findUserInfo(_user,_lid); //通过数据库,以bean返回值
     if(userInfo!=null)
     {
              UserInfoForm userInfoForm = (UserInfoForm) form;
     userInfoForm.setUserInfo(userInfo);           //把值赋于bean
     }Form中:
        private String sexId;
        private TUserinfo userInfo;
    ....
    public String getSexId() {
    return sexId;
    } public void setSexId(String sexId) {
    this.sexId = sexId;
    } public void setUserInfo(TUserinfo userInfo) {
    this.userInfo = userInfo;
    this.linkMan = userInfo.getLinkman();
    this.sexId = userInfo.getSex().getSexid()+"";
    this.linkmanDepartment = userInfo.getLinkmandepartment();
    this.linkmanPosition = userInfo.getLinkmanposition();
    this.telCountry = userInfo.getTelcountry();
    this.telCity = userInfo.getTelcity();
    this.telBase = userInfo.getTelbase();
    this.faxCountry = userInfo.getFaxcountry();
    this.faxCity = userInfo.getFaxcity();
    this.faxBase = userInfo.getFaxbase();
    this.mobie = userInfo.getMobie();
    this.address = userInfo.getAddress();
    this.post = userInfo.getPost();
    this.email = userInfo.getEmail();
    this.url = userInfo.getUrl();
    }Jsp中:
               <tr bgcolor="#FFFFFF">
                  <td align="right" bgcolor="#EEFFEF"><div align="right"><span class="orange">*</span>性别:</div></td>
                  <td><html:radio property="sexId" value="1" >
                      先生</html:radio> &nbsp;
                      <html:radio property="sexId" value="2">
                      女士</html:radio></td>
                </tr>
      

  11.   

    谢谢楼上的,我再试试.刚才不报错,什么也不显示.应该是null值.
      

  12.   

    <html:radio property="radioStation" value="left">左边显示
                                </html:radio>
                                <html:radio property="radioStation" value="right">右边显示
                                </html:radio>
                                <jsp:getProperty name="siteStyle" property="radioStation"/>
    ----------------------------------------------------
    jsp代码如上:<jsp:getProperty打印出来的值是left,但"左边显示"这个单选扭并不有选中.----------------------------------------------------
    下面是生成的html代码.
    <input type="radio" name="radioStation" value="left">左边显示
                                <input type="radio" name="radioStation" value="right">右边显示
                                left
      

  13.   

    <jsp:useBean id="siteStyle" scope="request" class="com.lideyong.server.bean.SiteStyle">
    </jsp:useBean>
    <%
    siteStyle.setSession(request.getSession());
    siteStyle.getThis();
    %>----------------------------以上是jsp里.------------------------
      

  14.   

    你的jsp里面的,用没有用<html:form method="post" action="/userInfoAdd.do" >?
    还是用<html>?
      

  15.   

    既然用了struts标签?为什么还混用jsp的?
    而struts中radio的内容必须 set/get方法
      

  16.   

    哦!我刚才试了一下就行了.
    原因get/set必须写在Struts的Form里才行,写在bean里并不能给struts的标签赋值呀!
      

  17.   

    晕,想从数据库获取数据再选中,直接在action里面set一下formbean中对应的属性就ok了
    真不知道为什么这个问题要讨论这么长
      

  18.   

    LZ刚刚学Struts吧~呵呵!慢慢来 不要急
      

  19.   

    在</html>的最后加上(就是说当页面执行完时)<script>
     document.all("sex")[0].checked=true;//第一个radio选中
    </script>龙卷风朋友说的才是正解!!