日期:2014-05-18  浏览次数:20692 次

嵌套的struts标签怎么写
有个页面   加载的时候   ,会从某个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: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);
}
%>
看看有输出没

------解决方案--------------------
<logic:present name= "questions ">

这句改为:

<logic:present name= "questions " scope= "request ">
------解决方案--------------------
<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就被选中,以此类推

------解决方案--------------------
struts标签是不能嵌套的
------解决方案--------------------
struts标签的潜逃是有问题的。
实在不行把html:radio换成最原始的input type= "radio ",
没有办法。只能出此下策。呵呵。
------解决方案--------------------
A <html:radio property= "question${question.liNum} " value= "sel_a " />
<bean:write name= "question " property= "sel_a " />

------解决方案--------------------
用Struts标签就是麻烦

干脆使用FreeMarker之类的模板好了
------解决方案--------------------
从上个action中传来的数据。但是这么写报错,
==========================================
什么错误啊
------解决方案--------------------
用JSTL标签
<logic:present name= "questions ">
<logic:iterate id= "question " name= "questions "
type= "com.exp.beans.QuestionsBean ">
${question.*******}