//大意是这样:当选择项与答案(question.answer)相同时,将该radio设置为checked。请问大家那个if表达式里
//内容该怎么写?
<s:iterator value="choiceList" status="sta">
(<s:property value="#sta.index+1"/>)、
      <s:property escape="false" value="question.content"/>(${question.score}分)
<s:iterator value="option">
        <s:if test="">
       <input type="radio" name="radio${question.id}" value="${sort}" checked="checked"/>&nbsp;${sort}. <s:property value="value"/>
       </s:if>
       <s:else>
       <input type="radio" name="radio${question.id}" value="${sort}"/>&nbsp;${sort}. <s:property value="value"/>
       </s:else> </s:iterator>
</s:iterator>

解决方案 »

  1.   

     <s:if test="">  就是这个里面怎么写?choiceList为action传过来的选择题集合,option为选项,里面有sort(A,B,C,D选项),value(选项内容)
      

  2.   

    或test="if(${question.answer}==${sort})",好像是这样的吧你试试
      

  3.   


    不行啊。而且test里面还要写if么。。?
     
      

  4.   

    不用struts标签,使用c:if标签呢?
      

  5.   

    <s:if test="%{question.answer==sort}">
      

  6.   

    或者<s:if test="question.answer==sort">
      

  7.   

    <s:if test="#question.answer==#sort">应该是这样吧。
      

  8.   

     <s:if test="${question.answer == sort}">
      

  9.   


    <c:choose>
    //使用jstl里的标签搞定了。。还是谢谢sbfivwsll(天涯浪子)
          <c:when test="${question.answer==sort}">
           <td height="30">
           <input type="radio" name="radio${question.id}" value="${sort}" checked="checked"/>&nbsp;${sort}. <s:property value="value"/>
           </td>
          </c:when>
           <c:otherwise>
            <td height="30">
           <input type="radio" name="radio${question.id}" value="${sort}" />&nbsp;${sort}. <s:property value="value"/>
           </td>
           </c:otherwise>
           </c:choose>
      

  10.   


    这个貌似是正确答案,我试了下,没出错。虽然用jstl做出来了,不过还是很感谢~
      

  11.   

    如果用<s:if test="${……}">  会提示"test" does not support runtime expressions  不能使用$吧应该