有个页面 加载的时候 ,会从某个action里传来数据
<logic:present name="questions">
<logic:iterate id="question" name="questions"
type="com.exp.beans.QuestionsBean">当本页面的form用到传过来的数据时,我写成下面这样,但是wsad警告说属性question没有值,查了一下指的是<bean:write  里面的question.,请问要达到这个效果,该怎么改呢?
<td align="center">A<html:radio
property="question<bean:write name="question" property="liNum" />"
value="sel_a" /> <bean:write name="question" property="sel_a" />
</html:radio></td>

解决方案 »

  1.   

    <logic:iterate id="question" name="questions" type="com.exp.beans.QuestionsBean">
         <bean:write name="question" property="sel_a" />
    </logic:iterate>
    这样做就可以了 循环输出
    属性question没有值?你把type去掉不用定义类型仔细检查传过来的 集合questions是否有内容
    可以做下测试
    <%
    List list=(List)request.getAttribute("questions");//或 session.getAttribute();
    for(int i=0;i<list.size();i++){
      QuestionsBean q=(QuestionsBean)list.get(i);
      out.println(q.getLiNum);
    }
    %>
    看看有输出没
      

  2.   

    <logic:iterate id="question" name="questions" type="com.exp.beans.QuestionsBean">
         <bean:write name="question" property="sel_a" />
    </logic:iterate>
    我知道这样可以输出,但是我想做到的是用这些前面传过来的数据给当前页面表单中的元素付值。
      

  3.   

    就是一个试题4个选项,都属于同一个property="question*";
    *这里动态的由前面传过来的行号设定;
    就是这个效果,大家有什么办法么?
      

  4.   

    <logic:present name="questions">这句改为:  <logic:present name="questions" scope="request">
      

  5.   

    <logic:iterate id="question" name="questions" indexId="i">
        ..........property='question<%=i%>' />
    </logic:iterate>
    你的四个选项肯定是做成radiobutton的吧,你可以用一个property,然后做四个radiobutton
    比如<html radio.....property="question<%=i%>",value="A">
    <html radio.....property="question<%=i%>",value="B">
    <html radio.....property="question<%=i%>",value="C">
    <html radio.....property="question<%=i%>",value="D">然后你设置questioni是A那么A就被选中,以此类推
      

  6.   

    对啊,我就是这么弄得不过<%=i%>,换成了<bean:write name="question" property="liNum" />
    从上个action中传来的数据。但是这么写报错,
    为什么呢?
      

  7.   

    struts标签的潜逃是有问题的。
    实在不行把html:radio换成最原始的input type="radio",
    没有办法。只能出此下策。呵呵。
      

  8.   

    A<html:radio property="question${question.liNum}" value="sel_a" /> 
    <bean:write name="question" property="sel_a" />
      

  9.   

    用Struts标签就是麻烦干脆使用FreeMarker之类的模板好了
      

  10.   

    从上个action中传来的数据。但是这么写报错,
    ==========================================
    什么错误啊
      

  11.   

    用JSTL标签
    <logic:present name="questions">
    <logic:iterate id="question" name="questions"
    type="com.exp.beans.QuestionsBean">
    ${question.*******}
      

  12.   

    LZ可以只用上面方法
    我更喜欢使用 JSTL
     <c:forEach item=${requestScope.questions} var="question">
      ${question.*******}
    </c:foaEach>
      

  13.   

    A<html:radio property="question${question.liNum}" value="sel_a" /> 
    <bean:write name="question" property="sel_a" />
    -----------------------------------------------------------
    貌似这里的 ${question.liNum}被当作字符串 不是动态的变量