struts <logic:iterate>遍历中 nested 属性显示不出来,请各位大大帮忙看看? 没有指定查找集合的作用域 <logic:iterate id="item" name="list" scope="request"> 这样就应该ok啦 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 谢谢楼上的回复,我加上了,但还是没有显示出来<logic:iterate id="item" name="list" scope="request"> <nested:nest property="district"><nested:write property="name"/> <!-- 前面的代码错误,应该是property="name" --></nested:nest> ......</logic:iterate> 不明白,建议楼主先检查一下Action的list是否有值,然后再看页面上能否显示 list 里是有值的,也不报异常,就是值没有显示到页面 <logic:iterate id="item" name="list" scope="request"> 这里加了没?如果加了你struts.xml中这个对应的action元素 中加个scope=request这个属性试试 <logic:iterate id="item" name="list" scope="request"> 这里加了的,struts.xml里也加了scope=request属性的 是只有<nested:nest property="district"> <nested:write property="chainStore.district.name"/> </nested:nest> 部分的内容没有么 恩,就是这个<td></td>之间的内容没有 list是有值的,其他属性根据list取值都在页面上显示出来了,只有<td width="50"><nested:nest property="district"><nested:write property="chainStore.district.name"/></nested:nest></td> 是空白的,感觉标签没有生效一样,而且查看属性district也是有值的。你们类似的操作时是怎么用的?就是 bean chainStore有属性district,而district又是个bean,怎么引用district的属性,比如name,code等。用struts2时直接用district.name就可以了,但struts里怎么弄也不行我查了网上的<logic:iterate>可以嵌套好几层,我试了也不行啊.. nested:nest 标签所指定的属性应该是当前上下文的,如果是在 <html:form 里面,上下文就是 form,它会从 当前form里找 指定的属性,可能是你的上下文有问题吧。你试一下用 nested:root 标签指定下你的上下文看看。 搞定,13楼的兄弟(是兄弟吧?)正解,就是这个 nested:root 了,可以结账了!正确的显示代码如下:<logic:iterate id="item" name="list"> <tr align="center"> <td width="50"> <nested:root name="item"> <nested:nest property="district"> <nested:write property="name" /> </nested:nest> </nested:root> </td> <td width="50"> <bean:write name="item" property="code" /> </td> ......... </tr></logic:iterate> 我是前段时间弄那个 ajax 和 nest 标签的问题时候知道的不过我那个问题还没解决 呢 对后台进行管理 heritrix定制获取动态页面问题,菜鸟求教! 我的妈呀,一个EL函数截取字符串的问题,连老师的都…… jsp连接mysql 问题请教 URL提交表单问题~~~~~~ 急求JBOSS4.0.2连接池配置..会的朋友帮帮忙~ 关于log4j的问题!求您帮个忙,解决一下!在线等!!! 高手指点:用jbuilderX打开struts-logic.tld、struts-html.tld和struts-bean.tld是出现乱码,怎么解决? EJB??? 请教EJB的开发方式。 struts.xml所遇到的问题请教 还是解析xml的问题
<logic:iterate id="item" name="list" scope="request"> <nested:nest property="district">
<nested:write property="name"/> <!-- 前面的代码错误,应该是property="name" -->
</nested:nest>
......</logic:iterate>
这里加了没?
如果加了
你struts.xml
中这个对应的action元素 中加个scope=request这个属性试试
<nested:nest property="district">
<nested:write property="chainStore.district.name"/>
</nested:nest>
部分的内容没有么
<td width="50">
<nested:nest property="district">
<nested:write property="chainStore.district.name"/>
</nested:nest>
</td>
是空白的,感觉标签没有生效一样,而且查看属性district也是有值的。你们类似的操作时是怎么用的?就是 bean chainStore有属性district,而district又是个bean,怎么引用district的属性,比如name,code等。用struts2时直接用district.name就可以了,但struts里怎么弄也不行我查了网上的<logic:iterate>可以嵌套好几层,我试了也不行啊..
如果是在 <html:form 里面,上下文就是 form,
它会从 当前form里找 指定的属性,
可能是你的上下文有问题吧。
你试一下用 nested:root 标签指定下你的上下文看看。
<tr align="center">
<td width="50">
<nested:root name="item">
<nested:nest property="district">
<nested:write property="name" />
</nested:nest>
</nested:root>
</td>
<td width="50">
<bean:write name="item" property="code" />
</td>
.........
</tr>
</logic:iterate>
不过我那个问题还没解决 呢