有个页面 加载的时候 ,会从某个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>
<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>
<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);
}
%>
看看有输出没
<bean:write name="question" property="sel_a" />
</logic:iterate>
我知道这样可以输出,但是我想做到的是用这些前面传过来的数据给当前页面表单中的元素付值。
*这里动态的由前面传过来的行号设定;
就是这个效果,大家有什么办法么?
..........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就被选中,以此类推
从上个action中传来的数据。但是这么写报错,
为什么呢?
实在不行把html:radio换成最原始的input type="radio",
没有办法。只能出此下策。呵呵。
<bean:write name="question" property="sel_a" />
==========================================
什么错误啊
<logic:present name="questions">
<logic:iterate id="question" name="questions"
type="com.exp.beans.QuestionsBean">
${question.*******}
我更喜欢使用 JSTL
<c:forEach item=${requestScope.questions} var="question">
${question.*******}
</c:foaEach>
<bean:write name="question" property="sel_a" />
-----------------------------------------------------------
貌似这里的 ${question.liNum}被当作字符串 不是动态的变量